public final class Joiner extends Object implements Closeable
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_DELIMITER |
static String |
DEFAULT_KEY_VALUE_DELIMITER |
| Modifier and Type | Method and Description |
|---|---|
Joiner |
append(boolean element) |
Joiner |
append(char element) |
Joiner |
append(char[] element) |
Joiner |
append(char[] element,
int offset,
int len) |
Joiner |
append(CharSequence element) |
Joiner |
append(CharSequence element,
int start,
int end) |
Joiner |
append(double element) |
Joiner |
append(float element) |
Joiner |
append(int element) |
Joiner |
append(long element) |
Joiner |
append(Object element) |
Joiner |
append(String element) |
Joiner |
append(StringBuffer element) |
Joiner |
appendAll(boolean[] a) |
Joiner |
appendAll(boolean[] a,
int fromIndex,
int toIndex) |
Joiner |
appendAll(byte[] a) |
Joiner |
appendAll(byte[] a,
int fromIndex,
int toIndex) |
Joiner |
appendAll(char[] a) |
Joiner |
appendAll(char[] a,
int fromIndex,
int toIndex) |
Joiner |
appendAll(Collection<?> c) |
Joiner |
appendAll(Collection<?> c,
int fromIndex,
int toIndex) |
Joiner |
appendAll(double[] a) |
Joiner |
appendAll(double[] a,
int fromIndex,
int toIndex) |
Joiner |
appendAll(float[] a) |
Joiner |
appendAll(float[] a,
int fromIndex,
int toIndex) |
Joiner |
appendAll(int[] a) |
Joiner |
appendAll(int[] a,
int fromIndex,
int toIndex) |
Joiner |
appendAll(Iterable<?> iter) |
Joiner |
appendAll(Iterator<?> iter) |
Joiner |
appendAll(long[] a) |
Joiner |
appendAll(long[] a,
int fromIndex,
int toIndex) |
Joiner |
appendAll(Object[] a) |
Joiner |
appendAll(Object[] a,
int fromIndex,
int toIndex) |
Joiner |
appendAll(short[] a) |
Joiner |
appendAll(short[] a,
int fromIndex,
int toIndex) |
Joiner |
appendEntries(Map<?,?> m) |
Joiner |
appendEntries(Map<?,?> m,
int fromIndex,
int toIndex) |
Joiner |
appendEntries(Object entity) |
Joiner |
appendEntries(Object entity,
Collection<String> propNamesToAppend) |
Joiner |
appendEntriesExclusively(Object entity,
Set<String> propNamesToExeclude) |
Joiner |
appendEntry(Map.Entry<?,?> entry) |
Joiner |
appendEntry(String key,
boolean value) |
Joiner |
appendEntry(String key,
char value) |
Joiner |
appendEntry(String key,
char[] value) |
Joiner |
appendEntry(String key,
CharSequence value) |
Joiner |
appendEntry(String key,
double value) |
Joiner |
appendEntry(String key,
float value) |
Joiner |
appendEntry(String key,
int value) |
Joiner |
appendEntry(String key,
long value) |
Joiner |
appendEntry(String key,
Object value) |
Joiner |
appendEntry(String key,
String value) |
Joiner |
appendEntry(String key,
StringBuffer value) |
Joiner |
appendIf(boolean b,
Supplier<?> supplier) |
Joiner |
appendIfNotNull(Object element)
Append if not null.
|
void |
close()
Close.
|
static Joiner |
defauLt() |
int |
length() |
<T,E extends Exception> |
map(Throwables.Function<? super String,T,E> mapper)
The underline
StringBuilder will be recycled after this method is called if resueStringBuilder is set to true,
and should not continue to this instance. |
<T,E extends Exception> |
mapIfNotEmpty(Throwables.Function<? super String,T,E> mapper)
Call
mapper only if at least one element/object/entry is appended. |
Joiner |
merge(Joiner other)
Adds the contents of the given
StringJoiner without prefix and
suffix as the next element if it is non-empty. |
Joiner |
repeat(Object obj,
int n) |
Joiner |
repeat(String str,
int n) |
Joiner |
reuseCachedBuffer() |
Joiner |
reuseCachedBuffer(boolean useCachedBuffer)
Deprecated.
replaced with
reuseCachedBuffer() |
Joiner |
setEmptyValue(CharSequence emptyValue)
Sets the empty value.
|
Joiner |
skipNull(boolean skipNull)
Deprecated.
replaced with
skipNulls() |
Joiner |
skipNulls() |
String |
toString()
Returns the current value, consisting of the
prefix, the values
added so far separated by the delimiter, and the suffix,
unless no elements have been added in which case, the
prefix + suffix or the emptyValue characters are returned |
Joiner |
trim(boolean trim)
Deprecated.
replaced with
trimBeforeAppend() |
Joiner |
trimBeforeAppend() |
Joiner |
useForNull(String nullText)
Use for null.
|
static Joiner |
with(CharSequence delimiter) |
static Joiner |
with(CharSequence delimiter,
CharSequence keyValueDelimiter) |
static Joiner |
with(CharSequence delimiter,
CharSequence prefix,
CharSequence suffix) |
static Joiner |
with(CharSequence delimiter,
CharSequence keyValueDelimiter,
CharSequence prefix,
CharSequence suffix) |
public static final String DEFAULT_DELIMITER
public static final String DEFAULT_KEY_VALUE_DELIMITER
public static Joiner defauLt()
public static Joiner with(CharSequence delimiter)
delimiter - public static Joiner with(CharSequence delimiter, CharSequence keyValueDelimiter)
delimiter - keyValueDelimiter - public static Joiner with(CharSequence delimiter, CharSequence prefix, CharSequence suffix)
delimiter - prefix - suffix - public static Joiner with(CharSequence delimiter, CharSequence keyValueDelimiter, CharSequence prefix, CharSequence suffix)
delimiter - keyValueDelimiter - prefix - suffix - public Joiner setEmptyValue(CharSequence emptyValue)
emptyValue - @Deprecated public Joiner trim(boolean trim)
trimBeforeAppend()trim - public Joiner trimBeforeAppend()
@Deprecated public Joiner skipNull(boolean skipNull)
skipNulls()null element/value for key/value, Map, Entity when the specified element or value is null if it's set to true.skipNull - public Joiner skipNulls()
@Deprecated public Joiner reuseCachedBuffer(boolean useCachedBuffer)
reuseCachedBuffer()useCachedBuffer=true, and must remember to call toString()/map()/mapIfNotEmpty()/stream()/streamIfNotEmpty() or close() to recycle the cached buffer.useCachedBuffer - public Joiner reuseCachedBuffer()
public Joiner append(boolean element)
element - public Joiner append(char element)
element - public Joiner append(int element)
element - public Joiner append(long element)
element - public Joiner append(float element)
element - public Joiner append(double element)
element - public Joiner append(CharSequence element)
element - public Joiner append(CharSequence element, int start, int end)
element - start - end - public Joiner append(StringBuffer element)
element - public Joiner append(char[] element)
element - public Joiner append(char[] element, int offset, int len)
element - offset - len - public Joiner appendIfNotNull(Object element)
element - public Joiner appendIf(boolean b, Supplier<?> supplier)
b - supplier - public Joiner appendAll(boolean[] a)
a - public Joiner appendAll(boolean[] a, int fromIndex, int toIndex)
a - fromIndex - toIndex - public Joiner appendAll(char[] a)
a - public Joiner appendAll(char[] a, int fromIndex, int toIndex)
a - fromIndex - toIndex - public Joiner appendAll(byte[] a)
a - public Joiner appendAll(byte[] a, int fromIndex, int toIndex)
a - fromIndex - toIndex - public Joiner appendAll(short[] a)
a - public Joiner appendAll(short[] a, int fromIndex, int toIndex)
a - fromIndex - toIndex - public Joiner appendAll(int[] a)
a - public Joiner appendAll(int[] a, int fromIndex, int toIndex)
a - fromIndex - toIndex - public Joiner appendAll(long[] a)
a - public Joiner appendAll(long[] a, int fromIndex, int toIndex)
a - fromIndex - toIndex - public Joiner appendAll(float[] a)
a - public Joiner appendAll(float[] a, int fromIndex, int toIndex)
a - fromIndex - toIndex - public Joiner appendAll(double[] a)
a - public Joiner appendAll(double[] a, int fromIndex, int toIndex)
a - fromIndex - toIndex - public Joiner appendAll(Object[] a, int fromIndex, int toIndex)
a - fromIndex - toIndex - public Joiner appendAll(Collection<?> c)
c - public Joiner appendAll(Collection<?> c, int fromIndex, int toIndex)
c - fromIndex - toIndex - public Joiner appendEntry(String key, CharSequence value)
key - value - public Joiner appendEntry(String key, StringBuffer value)
key - value - public Joiner appendEntries(Map<?,?> m, int fromIndex, int toIndex)
m - fromIndex - toIndex - public Joiner appendEntries(Object entity)
entity - entity class with getter/setter methods.public Joiner appendEntries(Object entity, Collection<String> propNamesToAppend)
entity - entity class with getter/setter methods.propNamesToAppend - public Joiner appendEntriesExclusively(Object entity, Set<String> propNamesToExeclude)
entity - entity class with getter/setter methods.propNamesToAppend - public Joiner merge(Joiner other)
StringJoiner without prefix and
suffix as the next element if it is non-empty. If the given StringJoiner is empty, the call has no effect.
A StringJoiner is empty if add()
has never been called, and if merge() has never been called
with a non-empty StringJoiner argument.
If the other StringJoiner is using a different delimiter,
then elements from the other StringJoiner are concatenated with
that delimiter and the result is appended to this StringJoiner
as a single element.
Remember to close other Joiner if reuseCachedBuffer is set to true.
other - The StringJoiner whose contents should be merged
into this oneStringJoinerNullPointerException - if the other StringJoiner is nullpublic int length()
public String toString()
prefix, the values
added so far separated by the delimiter, and the suffix,
unless no elements have been added in which case, the
prefix + suffix or the emptyValue characters are returned
The underlineStringBuilderwill be recycled after this method is called ifresueStringBuilderis set totrue, and should not continue to this instance.
public <T,E extends Exception> T map(Throwables.Function<? super String,T,E> mapper) throws E extends Exception
The underlineStringBuilderwill be recycled after this method is called ifresueStringBuilderis set totrue, and should not continue to this instance.
T - E - mapper - E - the eE extends Exceptionpublic <T,E extends Exception> u.Nullable<T> mapIfNotEmpty(Throwables.Function<? super String,T,E> mapper) throws E extends Exception
mapper only if at least one element/object/entry is appended.
The underlineStringBuilderwill be recycled after this method is called ifresueStringBuilderis set totrue, and should not continue to this instance.
T - E - mapper - E - the eE extends Exceptionpublic void close()
close in interface Closeableclose in interface AutoCloseableCopyright © 2021. All rights reserved.