@Test public void testGeoFromAttributes() throws Exception { Map<String, String> attributes = ImmutableMap.of("geo_country", "CA", "sample_id", "15", "geo_city", "Whistler"); ObjectNode geo = NestedMetadata.geoFromAttributes(attributes); ObjectNode expected = mapToObjectNode(ImmutableMap.of("country", "CA", "city", "Whistler")); assertEquals(expected, geo); }
static ObjectNode geoFromAttributes(Map<String, String> attributes) { ObjectNode geo = Json.createObjectNode(); attributes.keySet().stream() .filter(k -> k.startsWith(GEO_PREFIX)) .forEach(k -> geo.put(k.substring(4), attributes.get(k))); return geo; }
NestedMetadata { static ObjectNode geoFromAttributes(Map<String, String> attributes) { ObjectNode geo = Json.createObjectNode(); attributes.keySet().stream() .filter(k -> k.startsWith(GEO_PREFIX)) .forEach(k -> geo.put(k.substring(4), attributes.get(k))); return geo; } }
NestedMetadata { static ObjectNode geoFromAttributes(Map<String, String> attributes) { ObjectNode geo = Json.createObjectNode(); attributes.keySet().stream() .filter(k -> k.startsWith(GEO_PREFIX)) .forEach(k -> geo.put(k.substring(4), attributes.get(k))); return geo; } private  NestedMetadata(); }
NestedMetadata { static ObjectNode geoFromAttributes(Map<String, String> attributes) { ObjectNode geo = Json.createObjectNode(); attributes.keySet().stream() .filter(k -> k.startsWith(GEO_PREFIX)) .forEach(k -> geo.put(k.substring(4), attributes.get(k))); return geo; } private  NestedMetadata(); static byte[] mergedPayload(byte[] payload, byte[] metadata); static ObjectNode attributesToMetadataPayload(Map<String, String> attributes); static void stripPayloadMetadataToAttributes(Map<String, String> attributes,
      ObjectNode payload); }
NestedMetadata { static ObjectNode geoFromAttributes(Map<String, String> attributes) { ObjectNode geo = Json.createObjectNode(); attributes.keySet().stream() .filter(k -> k.startsWith(GEO_PREFIX)) .forEach(k -> geo.put(k.substring(4), attributes.get(k))); return geo; } private  NestedMetadata(); static byte[] mergedPayload(byte[] payload, byte[] metadata); static ObjectNode attributesToMetadataPayload(Map<String, String> attributes); static void stripPayloadMetadataToAttributes(Map<String, String> attributes,
      ObjectNode payload);  }