@Override public String toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("InnerMetricContext Name: "); stringBuilder.append(this.name); if (this.getParent().isPresent()) { stringBuilder.append(", Parent Name: "); stringBuilder.append(this.getParent().get().getName()); } else { stringBuilder.append(", No Parent Context"); } stringBuilder.append(", Number of Children: "); stringBuilder.append(this.getChildContextsAsMap().size()); stringBuilder.append(", Tags: "); stringBuilder.append(Joiner.on(", ").withKeyValueSeparator(" : ").useForNull("NULL").join(this.getTagMap())); return stringBuilder.toString(); } }
public void testMap() { MapJoiner j = Joiner.on(';').withKeyValueSeparator(':'); assertEquals("", j.join(ImmutableMap.of())); assertEquals(":", j.join(ImmutableMap.of("", ""))); Map<String, String> mapWithNulls = Maps.newLinkedHashMap(); mapWithNulls.put("a", null); mapWithNulls.put(null, "b"); try { j.join(mapWithNulls); fail(); } catch (NullPointerException expected) { } assertEquals("a:00;00:b", j.useForNull("00").join(mapWithNulls)); StringBuilder sb = new StringBuilder(); j.appendTo(sb, ImmutableMap.of(1, 2, 3, 4, 5, 6)); assertEquals("1:2;3:4;5:6", sb.toString()); }
assertEquals("a:00;00:b", j.useForNull("00").join(entriesWithNulls)); assertEquals("a:00;00:b", j.useForNull("00").join(entriesWithNulls.iterator()));
Object[] args = {Joiner.on("], [").withKeyValueSeparator(" = ").useForNull("null").join(foundValues), value};
assertEquals("a:00;00:b", j.useForNull("00").join(entriesWithNulls)); assertEquals("a:00;00:b", j.useForNull("00").join(entriesWithNulls.iterator()));
public void run(String pcapReaderClass, String path) throws IOException { Joiner.MapJoiner mapJoiner = Joiner.on('\n').withKeyValueSeparator(": ").useForNull("null"); InputStream is = null; try { long packets = 0; System.out.println("=== START ==="); is = new FileInputStream(path); if (path.endsWith(".gz") || path.endsWith(".gzip")) is = new GZIPInputStream(is); PcapReader reader = initPcapReader(pcapReaderClass, new DataInputStream(is)); for (Packet packet : reader) { System.out.println("--- Packet ---"); System.out.println(mapJoiner.join(packet)); System.out.println(); packets++; } System.out.println("=== STOP ==="); System.out.println("Packets: " + packets); } finally { if (is != null) is.close(); } }
public void testMap() { MapJoiner j = Joiner.on(';').withKeyValueSeparator(':'); assertEquals("", j.join(ImmutableMap.of())); assertEquals(":", j.join(ImmutableMap.of("", ""))); Map<String, String> mapWithNulls = Maps.newLinkedHashMap(); mapWithNulls.put("a", null); mapWithNulls.put(null, "b"); try { j.join(mapWithNulls); fail(); } catch (NullPointerException expected) { } assertEquals("a:00;00:b", j.useForNull("00").join(mapWithNulls)); StringBuilder sb = new StringBuilder(); j.appendTo(sb, ImmutableMap.of(1, 2, 3, 4, 5, 6)); assertEquals("1:2;3:4;5:6", sb.toString()); }
@Override public String toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("InnerMetricContext Name: "); stringBuilder.append(this.name); if (this.getParent().isPresent()) { stringBuilder.append(", Parent Name: "); stringBuilder.append(this.getParent().get().getName()); } else { stringBuilder.append(", No Parent Context"); } stringBuilder.append(", Number of Children: "); stringBuilder.append(this.getChildContextsAsMap().size()); stringBuilder.append(", Tags: "); stringBuilder.append(Joiner.on(", ").withKeyValueSeparator(" : ").useForNull("NULL").join(this.getTagMap())); return stringBuilder.toString(); } }
@Override public String toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("InnerMetricContext Name: "); stringBuilder.append(this.name); if (this.getParent().isPresent()) { stringBuilder.append(", Parent Name: "); stringBuilder.append(this.getParent().get().getName()); } else { stringBuilder.append(", No Parent Context"); } stringBuilder.append(", Number of Children: "); stringBuilder.append(this.getChildContextsAsMap().size()); stringBuilder.append(", Tags: "); stringBuilder.append(Joiner.on(", ").withKeyValueSeparator(" : ").useForNull("NULL").join(this.getTagMap())); return stringBuilder.toString(); } }
private String buildFieldsSpec(@NotNull Map<String, String> fields) { return Joiner.on(',').withKeyValueSeparator("=").useForNull("null").join(fields); } }
public void save() throws IOException { if (file != null) { file.getAbsoluteFile().getParentFile().mkdirs(); String data = Joiner.on('\n').withKeyValueSeparator(" = ").useForNull("").join(configuration.entries()) + "\n"; Files.write(data, file, Charsets.UTF_8); } }
@Override public String toString() { return new StringBuilder("{") .append(Joiner.on(", ") .withKeyValueSeparator(": ") .useForNull("null") .join(this)) .append("}") .toString(); }
public void save() throws IOException { if (file != null) { file.getAbsoluteFile().getParentFile().mkdirs(); String data = Joiner.on('\n').withKeyValueSeparator(" = ").useForNull("").join(configuration.entries()) + "\n"; Files.write(data, file, Charsets.UTF_8); } }
public void save() throws IOException { if (file != null) { file.getAbsoluteFile().getParentFile().mkdirs(); String data = Joiner.on('\n').withKeyValueSeparator(" = ").useForNull("").join(configuration.entries()) + "\n"; Files.write(data, file, Charsets.UTF_8); } }
public static String MapListToString(Map<String, List<String>> l) { Joiner.MapJoiner mapJoiner = Joiner.on('\n').withKeyValueSeparator("=").useForNull("NULL"); return mapJoiner.join(l); }
@Override public String toString() { return Objects.toStringHelper(this) .add("metricName", metricName) .add("tagValues", Joiner.on(",").withKeyValueSeparator(":").useForNull("null").join(tagValues)) .add("timeValues", Joiner.on(",").join(timeValues)).toString(); } }
@Override public String toString() { return Objects.toStringHelper(this) .add("startTs", startTs) .add("endTs", endTs) .add("resolution", resolution) .add("metrics", metrics) .add("sliceByTags", Joiner.on(",").withKeyValueSeparator(":").useForNull("null").join(sliceByTagValues)) .add("groupByTags", Joiner.on(",").join(groupByTags)).toString(); } }
@Override public String toString() { return Objects.toStringHelper(this) .add("startTs", startTs) .add("endTs", endTs) .add("metricName", metricNames) .add("sliceByTags", Joiner.on(",").withKeyValueSeparator(":").useForNull("null").join(sliceByTagValues)) .toString(); } }