Yamls { @Beta public static Object getAt(String yaml, List<String> path) { Iterable<Object> result = newYaml().loadAll(yaml); Object current = result.iterator().next(); return getAtPreParsed(current, path); }  @SuppressWarnings({ "unchecked", "rawtypes" }) static T getAs(Object x, Class<T> type); @Beta static Object getAt(String yaml, List<String> path); @Beta @SuppressWarnings("unchecked") static Object getAtPreParsed(Object current, List<String> path); @SuppressWarnings("rawtypes") static void dump(int depth, Object r); @SuppressWarnings("unchecked") static Iterable<Object> parseAll(String yaml); @SuppressWarnings("unchecked") static Iterable<Object> parseAll(Reader yaml); static Object removeMultinameAttribute(Map<String,Object> obj, String ...equivalentNames); static Object getMultinameAttribute(Map<String,Object> obj, String ...equivalentNames); static YamlExtract getTextOfYamlAtPath(String yaml, Object ...path);  }
@Test public void testGetAt() throws Exception { assertEquals(Yamls.getAt("k1: v", ImmutableList.of("k1")), "v"); assertEquals(Yamls.getAt("k1: {k2: v}", ImmutableList.of("k1", "k2")), "v"); assertEquals(Yamls.getAt("k1: [v1, v2]", ImmutableList.<String>of("k1")), ImmutableList.of("v1", "v2")); assertEquals(Yamls.getAt("k1: v", ImmutableList.<String>of()), ImmutableMap.of("k1", "v")); assertEquals(Yamls.getAt("k1: {k2: v}", ImmutableList.of("k1")), ImmutableMap.of("k2", "v")); assertEquals(Yamls.getAt("k1: [v1, v2]", ImmutableList.<String>of("k1", "[0]")), "v1"); assertEquals(Yamls.getAt("k1: [v1, v2]", ImmutableList.<String>of("k1", "[1]")), "v2"); }