Example usage for com.google.common.base Joiner withKeyValueSeparator

List of usage examples for com.google.common.base Joiner withKeyValueSeparator

Introduction

In this page you can find the example usage for com.google.common.base Joiner withKeyValueSeparator.

Prototype

@CheckReturnValue
public MapJoiner withKeyValueSeparator(String keyValueSeparator) 

Source Link

Document

Returns a MapJoiner using the given key-value separator, and the same configuration as this Joiner otherwise.

Usage

From source file:com.streamsets.pipeline.lib.el.StringEL.java

@ElFunction(prefix = "map", name = "join", description = "Returns each element of a LIST field joined on the specified character sequence.")
public static String joinMap(@ElParam("map") Map<String, Field> map, @ElParam("separator") String separator,
        @ElParam("keyValueSeparator") String kvSeparator) {
    if (map == null) {
        return "";
    }//from w ww . j a va 2 s .  c  o m

    Map<String, String> mapOfStrings = map.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey,
            e -> e.getValue().getValue() == null ? "null" : e.getValue().getValueAsString()));
    Joiner joiner = Joiner.on(separator);

    return joiner.withKeyValueSeparator(kvSeparator).join(mapOfStrings);
}

From source file:org.eclipse.viatra.query.patternlanguage.emf.validation.VariableReferenceCount.java

@Override
public String toString() {
    StringBuilder sb = new StringBuilder();
    if (parameter) {
        sb.append("Variable: ");
    } else {/*from   w  w w .  ja  v a2  s.  co m*/
        sb.append("Parameter: ");
    }
    sb.append("<");
    Joiner joiner = Joiner.on(", ");
    joiner.appendTo(sb, getVariables());
    sb.append("> ");
    joiner.withKeyValueSeparator("=").appendTo(sb, counters);
    sb.append(" ---- Total: ");
    sb.append(size);
    return sb.toString();
}