uk.gov.dstl.baleen.core.utils.yaml.YamlConfiguration.get()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(146)

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

YamlConfiguration.get介绍

暂无

代码示例

代码示例来源:origin: dstl/baleen

@Override
public <T> Optional<T> get(Class<T> clazz, String path) {
 return Optional.ofNullable(get(clazz, path, null));
}

代码示例来源:origin: dstl/baleen

@Test
public void testReadString() throws IOException {
 YamlConfiguration yc =
   new YamlConfiguration("example:\n  color: red\n  count: 7\n  list:\n  - a\n  - b\n  - c");
 assertTrue(yc.getAsList("example.list").containsAll(Arrays.asList("a", "b", "c")));
 assertEquals("red", yc.get(String.class, "example.color").get());
}

代码示例来源:origin: uk.gov.dstl.baleen/baleen-core

@Override
public <T> Optional<T> get(String path) {
 return Optional.ofNullable(get(path, null));
}

代码示例来源:origin: dstl/baleen

@Override
public <T> Optional<T> getFirst(Class<T> clazz, String... paths) {
 for (String path : Arrays.asList(paths)) {
  Optional<T> optional = get(clazz, path);
  if (optional.isPresent()) {
   return optional;
  }
 }
 return Optional.empty();
}

代码示例来源:origin: dstl/baleen

@Test
public void testGet() {
 assertTrue(config.get(Integer.class, INT_KEY).isPresent());
 assertEquals(7, (int) config.get(Integer.class, INT_KEY).get());
 assertFalse(config.get(Object.class, MISSING_KEY).isPresent());
}

代码示例来源:origin: dstl/baleen

@Test
public void testGetWithDefault() {
 assertEquals(7, (int) config.get(Integer.class, INT_KEY, 4));
 assertEquals(1, (int) config.get(Integer.class, MISSING_KEY, 1));
}

代码示例来源:origin: dstl/baleen

@Test
public void testGetObject() {
 Optional<Object> found = config.get("example");
 assertTrue(found.isPresent());
 assertTrue(found.get() instanceof Map);
}

相关文章