Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ public Double getDouble(String name) {

@Nullable
@Override
@SuppressWarnings("unchecked")
public <T> List<T> getScalarList(String name, Class<T> scalarType) {
if (!SUPPORTED_SCALAR_TYPES.contains(scalarType)) {
throw new DeclarativeConfigException(
Expand All @@ -208,28 +207,28 @@ public <T> List<T> getScalarList(String name, Class<T> scalarType) {
}
Object value = simpleEntries.get(name);
if (value instanceof List) {
List<Object> objectList = ((List<Object>) value);
List<?> objectList = (List<?>) value;
if (objectList.isEmpty()) {
return Collections.emptyList();
}
List<T> result =
(List<T>)
objectList.stream()
.map(
entry -> {
if (scalarType == String.class) {
return stringOrNull(entry, name);
} else if (scalarType == Boolean.class) {
return booleanOrNull(entry, name);
} else if (scalarType == Long.class) {
return longOrNull(entry, name);
} else if (scalarType == Double.class) {
return doubleOrNull(entry, name);
}
return null;
})
.filter(Objects::nonNull)
.collect(toList());
objectList.stream()
.map(
entry -> {
if (scalarType == String.class) {
return stringOrNull(entry, name);
} else if (scalarType == Boolean.class) {
return booleanOrNull(entry, name);
} else if (scalarType == Long.class) {
return longOrNull(entry, name);
} else if (scalarType == Double.class) {
return doubleOrNull(entry, name);
}
return null;
})
.filter(Objects::nonNull)
.map(scalarType::cast)
.collect(toList());
if (result.isEmpty()) {
return null;
}
Expand Down
Loading