@Test public void testGetAsList() { List<String> list = config.getAsList(LIST_KEY); assertTrue(list.containsAll(Arrays.asList("a", "b", "c"))); list = config.getAsList(MISSING_KEY); assertTrue(list.isEmpty()); }
@Override @SuppressWarnings("unchecked") public <T> List<T> getAsList(String path) { Optional<Object> o = internalGet(path); List<T> ret = Collections.emptyList(); if (o.isPresent() && o.get() instanceof List) { try { ret = (List<T>) o.get(); } catch (ClassCastException cce) { LOGGER.warn("Requested path is not a list of the correct type", cce); } } else { LOGGER.debug( "Path [{}] not found, or isn't an instanceof List - an empty list will be returned", path); } return ret; }
YamlConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> List<T> getAsList(String path) { Optional<Object> o = internalGet(path); List<T> ret = Collections.emptyList(); if (o.isPresent() && o.get() instanceof List) { try { ret = (List<T>) o.get(); } catch (ClassCastException cce) { LOGGER.warn("Requested path is not a list of the correct type", cce); } } else { LOGGER.debug( "Path [{}] not found, or isn't an instanceof List - an empty list will be returned", path); } return ret; } }
YamlConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> List<T> getAsList(String path) { Optional<Object> o = internalGet(path); List<T> ret = Collections.emptyList(); if (o.isPresent() && o.get() instanceof List) { try { ret = (List<T>) o.get(); } catch (ClassCastException cce) { LOGGER.warn("Requested path is not a list of the correct type", cce); } } else { LOGGER.debug( "Path [{}] not found, or isn't an instanceof List - an empty list will be returned", path); } return ret; } YamlConfiguration(Yaml yaml);  YamlConfiguration();  YamlConfiguration(File file);  YamlConfiguration(String yaml);  YamlConfiguration(Class<?> clazz, String resourcePath);  YamlConfiguration(InputStream inputStream); }
YamlConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> List<T> getAsList(String path) { Optional<Object> o = internalGet(path); List<T> ret = Collections.emptyList(); if (o.isPresent() && o.get() instanceof List) { try { ret = (List<T>) o.get(); } catch (ClassCastException cce) { LOGGER.warn("Requested path is not a list of the correct type", cce); } } else { LOGGER.debug( "Path [{}] not found, or isn't an instanceof List - an empty list will be returned", path); } return ret; } 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 @SuppressWarnings("unchecked") public <T> List<T> getAsList(String path) { Optional<Object> o = internalGet(path); List<T> ret = Collections.emptyList(); if (o.isPresent() && o.get() instanceof List) { try { ret = (List<T>) o.get(); } catch (ClassCastException cce) { LOGGER.warn("Requested path is not a list of the correct type", cce); } } else { LOGGER.debug( "Path [{}] not found, or isn't an instanceof List - an empty list will be returned", path); } return ret; } 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; }