public List getList()

in src/main/java/org/apache/commons/configuration2/AbstractConfiguration.java [1174:1200]


    public List<Object> getList(final String key, final List<?> defaultValue) {
        final Object value = getProperty(key);
        final List<Object> list;

        if (value instanceof String) {
            list = new ArrayList<>(1);
            list.add(interpolate((String) value));
        } else if (value instanceof List) {
            list = new ArrayList<>();
            final List<?> l = (List<?>) value;

            // add the interpolated elements in the new list
            l.forEach(elem -> list.add(interpolate(elem)));
        } else if (value == null) {
            // This is okay because we just return this list to the caller
            @SuppressWarnings("unchecked")
            final List<Object> resultList = (List<Object>) defaultValue;
            list = resultList;
        } else if (value.getClass().isArray()) {
            return Arrays.asList((Object[]) value);
        } else if (isScalarValue(value)) {
            return Collections.singletonList((Object) value.toString());
        } else {
            throw new ConversionException('\'' + key + "' doesn't map to a List object: " + value + ", a " + value.getClass().getName());
        }
        return list;
    }