Package com.google.common.base
Class Joiner
java.lang.Object
com.google.common.base.Joiner
Deprecated.
The Google Guava Core Libraries are deprecated and will not be part of the AEM SDK after April 2023
An object which joins pieces of text (specified as an array,
Iterable, varargs or even a
Map) with a separator. It either appends the results to an Appendable or returns
them as a String. Example:
Joiner joiner = Joiner.on("; ").skipNulls();
. . .
return joiner.join("Harry", null, "Ron", "Hermione");
This returns the string "Harry; Ron; Hermione". Note that all input elements are
converted to strings using Object.toString() before being appended.
If neither skipNulls() nor useForNull(String) is specified, the joining
methods will throw NullPointerException if any given element is null.
Warning: joiner instances are always immutable; a configuration method such as
useForNull has no effect on the instance it is invoked on! You must store and use the new joiner
instance returned by the method. This makes joiners thread-safe, and safe to store as
static final constants.
// Bad! Do not do this!
Joiner joiner = Joiner.on(',');
joiner.skipNulls(); // does nothing!
return joiner.join("wrong", null, "wrong");
See the Guava User Guide article on Joiner.
- Since:
- 2.0 (imported from Google Collections Library)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classDeprecated.The Google Guava Core Libraries are deprecated and will not be part of the AEM SDK after April 2023 -
Method Summary
Modifier and TypeMethodDescription<A extends Appendable>
ADeprecated.Appends the string representation of each ofparts, using the previously configured separator between each, toappendable.final <A extends Appendable>
ADeprecated.Appends the string representation of each ofparts, using the previously configured separator between each, toappendable.final <A extends Appendable>
ADeprecated.Appends toappendablethe string representation of each of the remaining arguments.<A extends Appendable>
ADeprecated.Appends the string representation of each ofparts, using the previously configured separator between each, toappendable.final StringBuilderappendTo(StringBuilder builder, Iterable<?> parts) Deprecated.Appends the string representation of each ofparts, using the previously configured separator between each, tobuilder.final StringBuilderappendTo(StringBuilder builder, Object[] parts) Deprecated.Appends the string representation of each ofparts, using the previously configured separator between each, tobuilder.final StringBuilderappendTo(StringBuilder builder, Object first, Object second, Object... rest) Deprecated.Appends tobuilderthe string representation of each of the remaining arguments.final StringBuilderappendTo(StringBuilder builder, Iterator<?> parts) Deprecated.Appends the string representation of each ofparts, using the previously configured separator between each, tobuilder.final StringDeprecated.Returns a string containing the string representation of each ofparts, using the previously configured separator between each.final StringDeprecated.Returns a string containing the string representation of each ofparts, using the previously configured separator between each.final StringDeprecated.Returns a string containing the string representation of each argument, using the previously configured separator between each.final StringDeprecated.Returns a string containing the string representation of each ofparts, using the previously configured separator between each.static Joineron(char separator) Deprecated.Returns a joiner which automatically placesseparatorbetween consecutive elements.static JoinerDeprecated.Returns a joiner which automatically placesseparatorbetween consecutive elements.Deprecated.Returns a joiner with the same behavior as this joiner, except automatically skipping over any provided null elements.useForNull(String nullText) Deprecated.Returns a joiner with the same behavior as this one, except automatically substitutingnullTextfor any provided null elements.withKeyValueSeparator(String keyValueSeparator) Deprecated.Returns aMapJoinerusing the given key-value separator, and the same configuration as thisJoinerotherwise.
-
Method Details
-
on
Deprecated.Returns a joiner which automatically placesseparatorbetween consecutive elements. -
on
Deprecated.Returns a joiner which automatically placesseparatorbetween consecutive elements. -
appendTo
Deprecated.Appends the string representation of each ofparts, using the previously configured separator between each, toappendable.- Throws:
IOException
-
appendTo
Deprecated.Appends the string representation of each ofparts, using the previously configured separator between each, toappendable.- Throws:
IOException- Since:
- 11.0
-
appendTo
Deprecated.Appends the string representation of each ofparts, using the previously configured separator between each, toappendable.- Throws:
IOException
-
appendTo
public final <A extends Appendable> A appendTo(A appendable, @Nullable Object first, @Nullable Object second, Object... rest) throws IOException Deprecated.Appends toappendablethe string representation of each of the remaining arguments.- Throws:
IOException
-
appendTo
Deprecated.Appends the string representation of each ofparts, using the previously configured separator between each, tobuilder. Identical toappendTo(Appendable, Iterable), except that it does not throwIOException. -
appendTo
Deprecated.Appends the string representation of each ofparts, using the previously configured separator between each, tobuilder. Identical toappendTo(Appendable, Iterable), except that it does not throwIOException.- Since:
- 11.0
-
appendTo
Deprecated.Appends the string representation of each ofparts, using the previously configured separator between each, tobuilder. Identical toappendTo(Appendable, Iterable), except that it does not throwIOException. -
appendTo
public final StringBuilder appendTo(StringBuilder builder, @Nullable Object first, @Nullable Object second, Object... rest) Deprecated.Appends tobuilderthe string representation of each of the remaining arguments. Identical toappendTo(Appendable, Object, Object, Object...), except that it does not throwIOException. -
join
Deprecated.Returns a string containing the string representation of each ofparts, using the previously configured separator between each. -
join
Deprecated.Returns a string containing the string representation of each ofparts, using the previously configured separator between each.- Since:
- 11.0
-
join
Deprecated.Returns a string containing the string representation of each ofparts, using the previously configured separator between each. -
join
Deprecated.Returns a string containing the string representation of each argument, using the previously configured separator between each. -
useForNull
Deprecated.Returns a joiner with the same behavior as this one, except automatically substitutingnullTextfor any provided null elements. -
skipNulls
Deprecated.Returns a joiner with the same behavior as this joiner, except automatically skipping over any provided null elements. -
withKeyValueSeparator
Deprecated.Returns aMapJoinerusing the given key-value separator, and the same configuration as thisJoinerotherwise.
-