public final class Strings extends Object
Strings.| Modifier and Type | Class and Description |
|---|---|
static class |
Strings.StringsToJoin
Knows how to join
Strings using a given delimiter. |
static class |
Strings.StringToAppend
Knows how to append a given
String to the given target, only if the target does not end with the given
String to append. |
| Modifier and Type | Method and Description |
|---|---|
static Strings.StringToAppend |
append(String toAppend)
Appends a given
String to the given target, only if the target does not end with the given String
to append. |
static String |
concat(Object... objects)
Concatenates the given objects into a single
String. |
static String |
escapePercent(String value)
|
static String |
formatIfArgs(String message,
Object... args)
Format with
String.format(String, Object...) the given message iif some args have been given otherwise juts
return the message. |
static boolean |
isNullOrEmpty(String s)
Indicates whether the given
String is null or empty. |
static Strings.StringsToJoin |
join(Iterable<?> toStringable)
Joins the given
Objects using a given delimiter. |
static Strings.StringsToJoin |
join(String... strings)
Joins the given
Strings using a given delimiter. |
static Object |
quote(Object o)
Returns the given object surrounded by single quotes, only if the object is a
String. |
static String |
quote(String s)
Returns the given
String surrounded by single quotes, or null if the given String is
null. |
public static boolean isNullOrEmpty(String s)
String is null or empty.s - the String to check.true if the given String is null or empty, otherwise false.public static String quote(String s)
String surrounded by single quotes, or null if the given String is
null.s - the given String.String surrounded by single quotes, or null if the given String is
null.public static Object quote(Object o)
String.o - the given object.String.quote(String)public static String concat(Object... objects)
String. This method is more efficient than concatenating using
"+", since only one StringBuilder is created.objects - the objects to concatenate.String containing the given objects.public static String formatIfArgs(String message, Object... args)
String.format(String, Object...) the given message iif some args have been given otherwise juts
return the message.message - the string to formatargs - args used to format the message, can be null or emptypublic static String escapePercent(String value)
value - the String to escapepublic static Strings.StringsToJoin join(String... strings)
Strings using a given delimiter. The following example illustrates proper usage of this
method:
Strings.join("a", "b", "c").with("|");
which will result in the String "a|b|c".strings - the Strings to join.Strings.Strings.StringsToJoin.with(String)public static Strings.StringsToJoin join(Iterable<?> toStringable)
Objects using a given delimiter. The following example illustrates proper usage of this
method:
Strings.join(new ArrayList("a", "b", "c")).with("|");
which will result in the String "a|b|c".toStringable - the Objects to join.Objects.Strings.StringsToJoin.with(String)public static Strings.StringToAppend append(String toAppend)
String to the given target, only if the target does not end with the given String
to append. The following example illustrates proper usage of this method:
Strings.append("c").to("ab");
Strings.append("c").to("abc");
resulting in the String "abc" for both cases.toAppend - the String to append.String and knows to append the given String.Strings.StringToAppend.to(String)Copyright © 2014–2019 AssertJ. All rights reserved.