Package com.google.common.base
Class Joiner.MapJoiner
- java.lang.Object
-
- com.google.common.base.Joiner.MapJoiner
-
- Enclosing class:
- Joiner
public static final class Joiner.MapJoiner extends Object
An object that joins map entries in the same manner asJoinerjoins iterables and arrays. LikeJoiner, it is thread-safe and immutable.In addition to operating on
Mapinstances,MapJoinercan operate onMultimapentries in two distinct modes:- To output a separate entry for each key-value pair, pass
multimap.entries()to aMapJoinermethod that accepts entries as input, and receive output of the formkey1=A&key1=B&key2=C. - To output a single entry for each key, pass
multimap.asMap()to aMapJoinermethod that accepts a map as input, and receive output of the formkey1=[A, B]&key2=C.
- Since:
- 2.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <A extends Appendable>
AappendTo(A appendable, Iterable<? extends Map.Entry<?,?>> entries)Appends the string representation of each entry inentries, using the previously configured separator and key-value separator, toappendable.<A extends Appendable>
AappendTo(A appendable, Iterator<? extends Map.Entry<?,?>> parts)Appends the string representation of each entry inentries, using the previously configured separator and key-value separator, toappendable.<A extends Appendable>
AappendTo(A appendable, Map<?,?> map)Appends the string representation of each entry ofmap, using the previously configured separator and key-value separator, toappendable.StringBuilderappendTo(StringBuilder builder, Iterable<? extends Map.Entry<?,?>> entries)Appends the string representation of each entry inentries, using the previously configured separator and key-value separator, tobuilder.StringBuilderappendTo(StringBuilder builder, Iterator<? extends Map.Entry<?,?>> entries)Appends the string representation of each entry inentries, using the previously configured separator and key-value separator, tobuilder.StringBuilderappendTo(StringBuilder builder, Map<?,?> map)Appends the string representation of each entry ofmap, using the previously configured separator and key-value separator, tobuilder.Stringjoin(Iterable<? extends Map.Entry<?,?>> entries)Returns a string containing the string representation of each entry inentries, using the previously configured separator and key-value separator.Stringjoin(Iterator<? extends Map.Entry<?,?>> entries)Returns a string containing the string representation of each entry inentries, using the previously configured separator and key-value separator.Stringjoin(Map<?,?> map)Returns a string containing the string representation of each entry ofmap, using the previously configured separator and key-value separator.Joiner.MapJoineruseForNull(String nullText)Returns a map joiner with the same behavior as this one, except automatically substitutingnullTextfor any provided null keys or values.
-
-
-
Method Detail
-
appendTo
@CanIgnoreReturnValue public <A extends Appendable> A appendTo(A appendable, Map<?,?> map) throws IOException
Appends the string representation of each entry ofmap, using the previously configured separator and key-value separator, toappendable.- Throws:
IOException
-
appendTo
@CanIgnoreReturnValue public StringBuilder appendTo(StringBuilder builder, Map<?,?> map)
Appends the string representation of each entry ofmap, using the previously configured separator and key-value separator, tobuilder. Identical toappendTo(Appendable, Map), except that it does not throwIOException.
-
appendTo
@Beta @CanIgnoreReturnValue public <A extends Appendable> A appendTo(A appendable, Iterable<? extends Map.Entry<?,?>> entries) throws IOException
Appends the string representation of each entry inentries, using the previously configured separator and key-value separator, toappendable.- Throws:
IOException- Since:
- 10.0
-
appendTo
@Beta @CanIgnoreReturnValue public <A extends Appendable> A appendTo(A appendable, Iterator<? extends Map.Entry<?,?>> parts) throws IOException
Appends the string representation of each entry inentries, using the previously configured separator and key-value separator, toappendable.- Throws:
IOException- Since:
- 11.0
-
appendTo
@Beta @CanIgnoreReturnValue public StringBuilder appendTo(StringBuilder builder, Iterable<? extends Map.Entry<?,?>> entries)
Appends the string representation of each entry inentries, using the previously configured separator and key-value separator, tobuilder. Identical toappendTo(Appendable, Iterable), except that it does not throwIOException.- Since:
- 10.0
-
appendTo
@Beta @CanIgnoreReturnValue public StringBuilder appendTo(StringBuilder builder, Iterator<? extends Map.Entry<?,?>> entries)
Appends the string representation of each entry inentries, using the previously configured separator and key-value separator, tobuilder. Identical toappendTo(Appendable, Iterable), except that it does not throwIOException.- Since:
- 11.0
-
join
public String join(Map<?,?> map)
Returns a string containing the string representation of each entry ofmap, using the previously configured separator and key-value separator.
-
join
@Beta public String join(Iterable<? extends Map.Entry<?,?>> entries)
Returns a string containing the string representation of each entry inentries, using the previously configured separator and key-value separator.- Since:
- 10.0
-
join
@Beta public String join(Iterator<? extends Map.Entry<?,?>> entries)
Returns a string containing the string representation of each entry inentries, using the previously configured separator and key-value separator.- Since:
- 11.0
-
useForNull
public Joiner.MapJoiner useForNull(String nullText)
Returns a map joiner with the same behavior as this one, except automatically substitutingnullTextfor any provided null keys or values.
-
-