@Test public void testMapFromYAML() throws Exception { try (InputStream is = MapsTest.class.getClassLoader().getResourceAsStream("simple.yml")) { Map<String, Object> map = Maps.fromYaml(is); checkFlattenMap(map); } }
public static Map<String, Object> fromYaml(InputStream is) { Map<String, Object> result = new HashMap<>(); Map<Object, Object> yaml = Serialization.unmarshal(is, new TypeReference<Map<Object, Object>>() { }); final Object prefixed = yaml.get(PROPERTY_PREFIX); if (prefixed != null) { Map<Object, Object> valueAsMap = (Map<Object, Object>) prefixed; for (Map.Entry<Object, Object> entry : valueAsMap.entrySet()) { Map<String, Object> kv = asMap(new String[] { String.valueOf(entry.getKey()) }, entry.getValue()); merge(result, kv); } } return result; }
Maps { public static Map<String, Object> fromYaml(InputStream is) { Map<String, Object> result = new HashMap<>(); Map<Object, Object> yaml = Serialization.unmarshal(is, new TypeReference<Map<Object, Object>>() { }); final Object prefixed = yaml.get(PROPERTY_PREFIX); if (prefixed != null) { Map<Object, Object> valueAsMap = (Map<Object, Object>) prefixed; for (Map.Entry<Object, Object> entry : valueAsMap.entrySet()) { Map<String, Object> kv = asMap(new String[] { String.valueOf(entry.getKey()) }, entry.getValue()); merge(result, kv); } } return result; } }
Maps { public static Map<String, Object> fromYaml(InputStream is) { Map<String, Object> result = new HashMap<>(); Map<Object, Object> yaml = Serialization.unmarshal(is, new TypeReference<Map<Object, Object>>() { }); final Object prefixed = yaml.get(PROPERTY_PREFIX); if (prefixed != null) { Map<Object, Object> valueAsMap = (Map<Object, Object>) prefixed; for (Map.Entry<Object, Object> entry : valueAsMap.entrySet()) { Map<String, Object> kv = asMap(new String[] { String.valueOf(entry.getKey()) }, entry.getValue()); merge(result, kv); } } return result; }  }
Maps { public static Map<String, Object> fromYaml(InputStream is) { Map<String, Object> result = new HashMap<>(); Map<Object, Object> yaml = Serialization.unmarshal(is, new TypeReference<Map<Object, Object>>() { }); final Object prefixed = yaml.get(PROPERTY_PREFIX); if (prefixed != null) { Map<Object, Object> valueAsMap = (Map<Object, Object>) prefixed; for (Map.Entry<Object, Object> entry : valueAsMap.entrySet()) { Map<String, Object> kv = asMap(new String[] { String.valueOf(entry.getKey()) }, entry.getValue()); merge(result, kv); } } return result; }  static Map<String, String> from(String... values); static Map<String, Object> fromProperties(Map<String, Object> properties); static Map<String, Object> fromProperties(InputStream is); static Map<String, Object> fromYaml(InputStream is); static Map<String, Object> fromAnnotation(String root, A annotation,
      Class<? extends A> type); static Map<String, Object> fromAnnotation(A annotation, Class<? extends A> type); static void merge(Map<String, Object> existing, Map<String, Object> map); static Map<String, T> kebabToCamelCase(Map<String, T> map); }
Maps { public static Map<String, Object> fromYaml(InputStream is) { Map<String, Object> result = new HashMap<>(); Map<Object, Object> yaml = Serialization.unmarshal(is, new TypeReference<Map<Object, Object>>() { }); final Object prefixed = yaml.get(PROPERTY_PREFIX); if (prefixed != null) { Map<Object, Object> valueAsMap = (Map<Object, Object>) prefixed; for (Map.Entry<Object, Object> entry : valueAsMap.entrySet()) { Map<String, Object> kv = asMap(new String[] { String.valueOf(entry.getKey()) }, entry.getValue()); merge(result, kv); } } return result; }  static Map<String, String> from(String... values); static Map<String, Object> fromProperties(Map<String, Object> properties); static Map<String, Object> fromProperties(InputStream is); static Map<String, Object> fromYaml(InputStream is); static Map<String, Object> fromAnnotation(String root, A annotation,
      Class<? extends A> type); static Map<String, Object> fromAnnotation(A annotation, Class<? extends A> type); static void merge(Map<String, Object> existing, Map<String, Object> map); static Map<String, T> kebabToCamelCase(Map<String, T> map);  }