Package org.assertj.core.util
Class Strings
java.lang.Object
org.assertj.core.util.Strings
Utility methods related to
Strings.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classKnows how to joinStrings using a given delimiter.static classKnows how to append a givenStringto the given target, only if the target does not end with the givenStringto append. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Strings.StringToAppendAppends a givenStringto the given target, only if the target does not end with the givenStringto append.static StringConcatenates the given objects into a singleString.static StringformatIfArgs(String message, Object... args) Format withString.format(String, Object...)the given message iif some args have been given otherwise juts return the message.static booleanIndicates whether the givenStringisnullor empty.static Strings.StringsToJoinJoins the givenObjects using a given delimiter.static Strings.StringsToJoinJoins the givenStrings using a given delimiter.static ObjectReturns the given object surrounded by single quotes, only if the object is aString.static StringReturns the givenStringsurrounded by single quotes, ornullif the givenStringisnull.
-
Constructor Details
-
Strings
private Strings()
-
-
Method Details
-
isNullOrEmpty
Indicates whether the givenStringisnullor empty.- Parameters:
s- theStringto check.- Returns:
trueif the givenStringisnullor empty, otherwisefalse.
-
quote
Returns the givenStringsurrounded by single quotes, ornullif the givenStringisnull.- Parameters:
s- the givenString.- Returns:
- the given
Stringsurrounded by single quotes, ornullif the givenStringisnull.
-
quote
Returns the given object surrounded by single quotes, only if the object is aString.- Parameters:
o- the given object.- Returns:
- the given object surrounded by single quotes, only if the object is a
String. - See Also:
-
concat
Concatenates the given objects into a singleString. This method is more efficient than concatenating using "+", since only oneis created.StringBuilder- Parameters:
objects- the objects to concatenate.- Returns:
- a
Stringcontaining the given objects.
-
formatIfArgs
Format withString.format(String, Object...)the given message iif some args have been given otherwise juts return the message.- Parameters:
message- the string to formatargs- args used to format the message, can be null or empty- Returns:
- the formatted string if any args were given
-
join
Joins the givenStrings using a given delimiter. The following example illustrates proper usage of this method:
which will result in theStrings.join("a", "b", "c").with("|");String"a|b|c".- Parameters:
strings- theStrings to join.- Returns:
- an intermediate object that takes a given delimiter and knows how to join the given
Strings. - See Also:
-
join
Joins the givenObjects using a given delimiter. The following example illustrates proper usage of this method:
which will result in theStrings.join(new ArrayList("a", "b", "c")).with("|");String"a|b|c".- Parameters:
toStringable- theObjects to join.- Returns:
- an intermediate object that takes a given delimiter and knows how to join the given
Objects. - See Also:
-
append
Appends a givenStringto the given target, only if the target does not end with the givenStringto append. The following example illustrates proper usage of this method:
resulting in theStrings.append("c").to("ab"); Strings.append("c").to("abc");String"abc"for both cases.- Parameters:
toAppend- theStringto append.- Returns:
- an intermediate object that takes the target
Stringand knows to append the givenString. - See Also:
-