/** Returns the canonical string format for the given {@link UserAgent}. */ public static String format(UserAgent userAgent) { Map<String, String> primaryComments = userAgent.nodeId().isPresent() ? ImmutableMap.of("nodeId", userAgent.nodeId().get()) : ImmutableMap.of(); return SPACE_JOINER.join(Iterables.concat( ImmutableList.of(formatSingleAgent(userAgent.primary(), primaryComments)), Lists.transform(userAgent.informational(), a -> formatSingleAgent(a, ImmutableMap.of())))); }