public MultimapJoiner skipNulls() { return new MultimapJoiner(entryJoiner.skipNulls(), separator, keyValueSeparator); }
/** * Appends the string representation of each entry of {@code map}, using the previously configured separator and * key-value separator, to {@code appendable}. */ public <A extends Appendable> A appendTo(A appendable, Map<?, ? extends Collection<?>> map) throws IOException { return appendTo(appendable, map.entrySet()); }
@Override protected CharSequence toString(Object part) { return (part == null) ? nullText : MultimapJoiner.this.toString(part); }
protected void appendListMapContent(/* @Nullable */ Map<?, ? extends Collection<?>> map, String prefix, StringBuilder result, String indentation) { if (map != null) { MultimapJoiner joiner = new MultimapJoiner( Joiner.on("\n " + indentation), "\n " + indentation, " ->\n" + indentation + " "); result.append("\n").append(indentation).append(prefix).append(":\n").append(indentation).append(" "); joiner.appendTo(result, map); } }
/** * Returns a string containing the string representation of each entry of {@code map}, using the previously * configured separator and key-value separator. */ public String join(Multimap<?, ?> map) { return join(map.asMap().entrySet()); }
/** * Appends the string representation of each entry of {@code map}, using the previously configured separator and * key-value separator, to {@code builder}. Identical to {@link #appendTo(Appendable, Map)}, except that it * does not throw {@link IOException}. */ public StringBuilder appendTo(StringBuilder builder, Map<?, ? extends Collection<?>> map) { return appendTo(builder, map.entrySet()); }
/** * Appends the string representation of each entry in {@code entries}, using the previously configured separator and * key-value separator, to {@code appendable}. */ public <A extends Appendable> A appendTo(A appendable, Iterable<? extends Entry<?, ? extends Collection<?>>> entries) throws IOException { // checkNotNull(appendable); Iterator<? extends Entry<?, ? extends Collection<?>>> iterator = entries.iterator(); if (iterator.hasNext()) { Entry<?, ? extends Collection<?>> entry = iterator.next(); appendable.append(toString(entry.getKey())); appendable.append(keyValueSeparator); entryJoiner.appendTo(appendable, entry.getValue()); while (iterator.hasNext()) { appendable.append(separator); Entry<?, ? extends Collection<?>> e = iterator.next(); appendable.append(toString(e.getKey())); appendable.append(keyValueSeparator); entryJoiner.appendTo(appendable, e.getValue()); } } return appendable; }
/** * Returns a multimap joiner with the same behavior as this one, except automatically substituting {@code nullText} for * any provided null keys or values. */ public MultimapJoiner useForNull(final String nullText) { return new MultimapJoiner(entryJoiner.useForNull(nullText), separator, keyValueSeparator) { @Override protected CharSequence toString(Object part) { return (part == null) ? nullText : MultimapJoiner.this.toString(part); } @Override public MultimapJoiner useForNull(String nullText) { throw new UnsupportedOperationException("already specified useForNull"); } @Override public MultimapJoiner skipNulls() { throw new UnsupportedOperationException("already specified useForNull"); } }; } }
/** * Appends the string representation of each entry in {@code entries}, using the previously configured separator and * key-value separator, to {@code builder}. Identical to {@link #appendTo(Appendable, Iterable)}, except that it * does not throw {@link IOException}. */ public StringBuilder appendTo(StringBuilder builder, Iterable<? extends Entry<?, ? extends Collection<?>>> entries) { try { appendTo((Appendable) builder, entries); } catch (IOException impossible) { throw new AssertionError(impossible); } return builder; }
/** * Appends the string representation of each entry of {@code map}, using the previously configured separator and * key-value separator, to {@code appendable}. */ public <A extends Appendable> A appendTo(A appendable, Multimap<?, ?> map) throws IOException { return appendTo(appendable, map.asMap().entrySet()); }
/** * Appends the string representation of each entry of {@code map}, using the previously configured separator and * key-value separator, to {@code builder}. Identical to {@link #appendTo(Appendable, Multimap)}, except that it * does not throw {@link IOException}. */ public StringBuilder appendTo(StringBuilder builder, Multimap<?, ?> map) { return appendTo(builder, map.asMap().entrySet()); }
/** * Returns a string containing the string representation of each entry in {@code entries}, using the previously * configured separator and key-value separator. */ public String join(Iterable<? extends Entry<?, ? extends Collection<?>>> entries) { return appendTo(new StringBuilder(), entries).toString(); }