/** * Returns a string containing the string representation of each entry in {@code entries}, using * the previously configured separator and key-value separator. * * @since 10.0 */ @Beta public String join(Iterable<? extends Entry<?, ?>> entries) { return join(entries.iterator()); }
/** * 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(Map<?, ?> map) { return join(map.entrySet()); }
/** * 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(Map<?, ?> map) { return join(map.entrySet()); }
@Override synchronized public String toString() { Map<Quantile, Long> data = snapshot(); if (data == null) { return "[no samples]"; } else { return Joiner.on("\n").withKeyValueSeparator(": ").join(data); } }
private static String stringMapToString(final Map<String, String> map) { return "{" + Joiner.on(", ").withKeyValueSeparator("=").join(map) + "}"; } }
String assembleQueryConfigUrl(String uri, String appId, String cluster, String namespace, String dataCenter, ApolloNotificationMessages remoteMessages, ApolloConfig previousConfig) { String path = "configs/%s/%s/%s"; List<String> pathParams = Lists.newArrayList(pathEscaper.escape(appId), pathEscaper.escape(cluster), pathEscaper.escape(namespace)); Map<String, String> queryParams = Maps.newHashMap(); if (previousConfig != null) { queryParams.put("releaseKey", queryParamEscaper.escape(previousConfig.getReleaseKey())); } if (!Strings.isNullOrEmpty(dataCenter)) { queryParams.put("dataCenter", queryParamEscaper.escape(dataCenter)); } String localIp = m_configUtil.getLocalIp(); if (!Strings.isNullOrEmpty(localIp)) { queryParams.put("ip", queryParamEscaper.escape(localIp)); } if (remoteMessages != null) { queryParams.put("messages", queryParamEscaper.escape(gson.toJson(remoteMessages))); } String pathExpanded = String.format(path, pathParams.toArray()); if (!queryParams.isEmpty()) { pathExpanded += "?" + MAP_JOINER.join(queryParams); } if (!uri.endsWith("/")) { uri += "/"; } return uri + pathExpanded; }
@Override public String toString() { Joiner.MapJoiner mapJoiner = Joiner.on(',').withKeyValueSeparator("="); return Objects.toStringHelper(this.getClass()).add("metadata", mapJoiner.join(this.values.get())).toString(); } }
@Override public String apply(Map<String, String> partitionDMLInfo) { if (partitionDMLInfo == null) { return StringUtils.EMPTY; } return String.format(" PARTITION (%s)", Joiner.on(",").withKeyValueSeparator("=").join(Maps.transformValues(partitionDMLInfo, QUOTE_PARTITION_VALUES))); } };
public static String asHeaders(final HttpMessage message) { return HEAD_JOINER.join(from(message.getHeaders().entrySet()) .transformAndConcat(toMapEntries())); }
/** * Parse a {@code Map<K, V>} data into string * * @param map the input data * @param <K> type parameter * @param <V> type parameter * @param sep separator * @return string of the input data */ public static <K, V> String toString(Map<K, V> map, String sep) { return Joiner.on(sep).withKeyValueSeparator(" -> ").join(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(Map<?, ?> map) { return join(map.entrySet()); }
@Override public String toString() { final Joiner.MapJoiner mapJoiner = Joiner.on("\n").withKeyValueSeparator("="); return mapJoiner.join(this.topicEventMap); } }
/** * Returns a string containing the string representation of each entry in {@code entries}, using * the previously configured separator and key-value separator. * * @since 10.0 */ @Beta public String join(Iterable<? extends Entry<?, ?>> entries) { return join(entries.iterator()); }
String assembleLongPollRefreshUrl(String uri, String appId, String cluster, String dataCenter, Map<String, Long> notificationsMap) { Map<String, String> queryParams = Maps.newHashMap(); queryParams.put("appId", queryParamEscaper.escape(appId)); queryParams.put("cluster", queryParamEscaper.escape(cluster)); queryParams .put("notifications", queryParamEscaper.escape(assembleNotifications(notificationsMap))); if (!Strings.isNullOrEmpty(dataCenter)) { queryParams.put("dataCenter", queryParamEscaper.escape(dataCenter)); } String localIp = m_configUtil.getLocalIp(); if (!Strings.isNullOrEmpty(localIp)) { queryParams.put("ip", queryParamEscaper.escape(localIp)); } String params = MAP_JOINER.join(queryParams); if (!uri.endsWith("/")) { uri += "/"; } return uri + "notifications/v2?" + params; }
@Override public String toString() { return "{" + Joiner.on(", ").withKeyValueSeparator(":").join(map) + "}"; }
public void testEntries() { MapJoiner j = Joiner.on(";").withKeyValueSeparator(":"); assertEquals("", j.join(ImmutableMultimap.of().entries())); assertEquals("", j.join(ImmutableMultimap.of().entries().iterator())); assertEquals(":", j.join(ImmutableMultimap.of("", "").entries())); assertEquals(":", j.join(ImmutableMultimap.of("", "").entries().iterator())); assertEquals("1:a;1:b", j.join(ImmutableMultimap.of("1", "a", "1", "b").entries())); assertEquals("1:a;1:b", j.join(ImmutableMultimap.of("1", "a", "1", "b").entries().iterator())); j.join(entriesWithNulls); fail(); } catch (NullPointerException expected) { j.join(entriesWithNulls.iterator()); fail(); } catch (NullPointerException expected) { assertEquals("a:00;00:b", j.useForNull("00").join(entriesWithNulls)); assertEquals("a:00;00:b", j.useForNull("00").join(entriesWithNulls.iterator()));
@Override public String toString() { String argsString = ""; if (args != null) { argsString = Joiner.on(", ") .withKeyValueSeparator(": ") .join(args.getArgs().entrySet().stream() .sorted((e1, e2) -> e1.getKey().compareTo(e2.getKey())) .iterator()); } return descriptor.name() + "(" + argsString + ")"; }
/** * Returns a string containing the string representation of each entry in {@code entries}, using * the previously configured separator and key-value separator. * * @since 10.0 */ @Beta public String join(Iterable<? extends Entry<?, ?>> entries) { return join(entries.iterator()); }
private String assembleMetaServiceUrl() { String domainName = m_configUtil.getMetaServerDomainName(); String appId = m_configUtil.getAppId(); String localIp = m_configUtil.getLocalIp(); Map<String, String> queryParams = Maps.newHashMap(); queryParams.put("appId", queryParamEscaper.escape(appId)); if (!Strings.isNullOrEmpty(localIp)) { queryParams.put("ip", queryParamEscaper.escape(localIp)); } return domainName + "/services/config?" + MAP_JOINER.join(queryParams); }
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()); }