gpt4 book ai didi

org.apache.brooklyn.util.yaml.Yamls.getAt()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 12:48:40 29 4
gpt4 key购买 nike

本文整理了Java中org.apache.brooklyn.util.yaml.Yamls.getAt()方法的一些代码示例,展示了Yamls.getAt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Yamls.getAt()方法的具体详情如下:
包路径:org.apache.brooklyn.util.yaml.Yamls
类名称:Yamls
方法名:getAt

Yamls.getAt介绍

[英]Parses the given yaml, and walks the given path to return the referenced object.
[中]解析给定的yaml,并沿着给定的路径返回引用的对象。

代码示例

代码示例来源:origin: io.cloudsoft.brooklyn.tosca/brooklyn-tosca-transformer

@SuppressWarnings("unchecked")
public static Iterable<String> getDefaultTypes() {
  String input = new ResourceUtils(null).getResourceAsString(CONFIG_URL);
  return (List) Yamls.getAt(input, ImmutableList.of("defaultTypes"));
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

@Test
public void testGetAt() throws Exception {
  // leaf of map
  assertEquals(Yamls.getAt("k1: v", ImmutableList.of("k1")), "v");
  assertEquals(Yamls.getAt("k1: {k2: v}", ImmutableList.of("k1", "k2")), "v");
  
  // get list
  assertEquals(Yamls.getAt("k1: [v1, v2]", ImmutableList.<String>of("k1")), ImmutableList.of("v1", "v2"));
  // get map
  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"));
  
  // get array index
  assertEquals(Yamls.getAt("k1: [v1, v2]", ImmutableList.<String>of("k1", "[0]")), "v1");
  assertEquals(Yamls.getAt("k1: [v1, v2]", ImmutableList.<String>of("k1", "[1]")), "v2");
}

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com