类 Joiner
- java.lang.Object
-
- net.dongliu.commons.Joiner
-
public class Joiner extends java.lang.ObjectA immutable value class for joining strings. This class is immutable, and should be reused across multi invocations of join with same rule.
-
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 java.lang.Stringjoin(@NonNull java.lang.Iterable<?> values)Join strings, with prefix, suffix, and delimiterjava.lang.Stringjoin(@Nullable java.lang.Object @NonNull ... values)Join strings, with prefix, suffix, and delimiterJoinernullToEmpty()Return a new Joiner which treat null elements as empty str instead of "null".static Joinerof(java.lang.CharSequence delimiter)Create new String Joiner.static Joinerof(java.lang.CharSequence prefix, java.lang.CharSequence suffix, java.lang.CharSequence delimiter)Create new String Joiner.JoinerskipEmpty()Return a new Joiner which skip empty strings.JoinerskipNulls()Return a new Joiner with skip the null elements.JoinerwithPrefix(java.lang.CharSequence prefix)Return a new Joiner which using the given prefix for joined string result.JoinerwithSuffix(java.lang.CharSequence suffix)Return a new Joiner which using the given suffix for joined string result.
-
-
-
方法详细资料
-
of
public static Joiner of(java.lang.CharSequence prefix, java.lang.CharSequence suffix, java.lang.CharSequence delimiter)
Create new String Joiner.- 参数:
prefix- the prefix to prepend, can not be nullsuffix- the suffix to append, can not be nulldelimiter- the delimiter to join multi string items, can not be null- 返回:
- Joiner
-
of
public static Joiner of(java.lang.CharSequence delimiter)
Create new String Joiner.- 参数:
delimiter- the delimiter to join multi string items, can not be null- 返回:
- Joiner
-
join
public java.lang.String join(@NonNull java.lang.Iterable<?> values)
Join strings, with prefix, suffix, and delimiter- 参数:
values- the string items- 返回:
- new string
-
join
public java.lang.String join(@Nullable java.lang.Object @NonNull ... values)
Join strings, with prefix, suffix, and delimiter- 参数:
values- the string items- 返回:
- new string
-
withPrefix
public Joiner withPrefix(java.lang.CharSequence prefix)
Return a new Joiner which using the given prefix for joined string result.
-
withSuffix
public Joiner withSuffix(java.lang.CharSequence suffix)
Return a new Joiner which using the given suffix for joined string result.
-
skipNulls
public Joiner skipNulls()
Return a new Joiner with skip the null elements.- 返回:
- new Joiner
-
nullToEmpty
public Joiner nullToEmpty()
Return a new Joiner which treat null elements as empty str instead of "null". This setting works only whenskipNullsis false- 返回:
- new Joiner
-
skipEmpty
public Joiner skipEmpty()
Return a new Joiner which skip empty strings. Set skipEmpty to true would not skip null values, but ifnullToEmptyis be set also, the null values would be skipped.
-
-