@Test public void testGetFirst() { assertEquals( "uk.gov.dstl.baleen.testing.DummyContentExtractor", config.getFirst(String.class, "contentextractor.class", "contentextractor").get()); assertEquals( "uk.gov.dstl.baleen.testing.DummyCollectionReader", config.getFirst(String.class, "collectionreader.class", "collectionreader").get()); Optional<String> found = config.getFirst(String.class, MISSING_KEY, "example", "missing"); assertFalse(found.isPresent()); }
@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(); }
YamlConfiguration implements Configuration { @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(); } }
YamlConfiguration implements Configuration { @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(); } YamlConfiguration(Yaml yaml);  YamlConfiguration();  YamlConfiguration(File file);  YamlConfiguration(String yaml);  YamlConfiguration(Class<?> clazz, String resourcePath);  YamlConfiguration(InputStream inputStream); }
YamlConfiguration implements Configuration { @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(); } YamlConfiguration(Yaml yaml);  YamlConfiguration();  YamlConfiguration(File file);  YamlConfiguration(String yaml);  YamlConfiguration(Class<?> clazz, String resourcePath);  YamlConfiguration(InputStream inputStream); @Override @SuppressWarnings("unchecked") List<T> getAsList(String path); @Override List<Map<String, Object>> getAsListOfMaps(String path); @Override Optional<T> get(Class<T> clazz, String path); @Override Optional<T> getFirst(Class<T> clazz, String... paths); @Override T get(Class<T> clazz, String path, T defaultValue); @Override String toString(); @Override String originalConfig(); }
YamlConfiguration implements Configuration { @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(); } YamlConfiguration(Yaml yaml);  YamlConfiguration();  YamlConfiguration(File file);  YamlConfiguration(String yaml);  YamlConfiguration(Class<?> clazz, String resourcePath);  YamlConfiguration(InputStream inputStream); @Override @SuppressWarnings("unchecked") List<T> getAsList(String path); @Override List<Map<String, Object>> getAsListOfMaps(String path); @Override Optional<T> get(Class<T> clazz, String path); @Override Optional<T> getFirst(Class<T> clazz, String... paths); @Override T get(Class<T> clazz, String path, T defaultValue); @Override String toString(); @Override String originalConfig(); static final char SEP; }