Skip to content

Commit 8a8cd79

Browse files
authored
Remove unchecked warning (#8090)
1 parent 85a44e8 commit 8a8cd79

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/YamlDeclarativeConfigProperties.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ public Double getDouble(String name) {
195195

196196
@Nullable
197197
@Override
198-
@SuppressWarnings("unchecked")
199198
public <T> List<T> getScalarList(String name, Class<T> scalarType) {
200199
if (!SUPPORTED_SCALAR_TYPES.contains(scalarType)) {
201200
throw new DeclarativeConfigException(
@@ -208,28 +207,28 @@ public <T> List<T> getScalarList(String name, Class<T> scalarType) {
208207
}
209208
Object value = simpleEntries.get(name);
210209
if (value instanceof List) {
211-
List<Object> objectList = ((List<Object>) value);
210+
List<?> objectList = (List<?>) value;
212211
if (objectList.isEmpty()) {
213212
return Collections.emptyList();
214213
}
215214
List<T> result =
216-
(List<T>)
217-
objectList.stream()
218-
.map(
219-
entry -> {
220-
if (scalarType == String.class) {
221-
return stringOrNull(entry, name);
222-
} else if (scalarType == Boolean.class) {
223-
return booleanOrNull(entry, name);
224-
} else if (scalarType == Long.class) {
225-
return longOrNull(entry, name);
226-
} else if (scalarType == Double.class) {
227-
return doubleOrNull(entry, name);
228-
}
229-
return null;
230-
})
231-
.filter(Objects::nonNull)
232-
.collect(toList());
215+
objectList.stream()
216+
.map(
217+
entry -> {
218+
if (scalarType == String.class) {
219+
return stringOrNull(entry, name);
220+
} else if (scalarType == Boolean.class) {
221+
return booleanOrNull(entry, name);
222+
} else if (scalarType == Long.class) {
223+
return longOrNull(entry, name);
224+
} else if (scalarType == Double.class) {
225+
return doubleOrNull(entry, name);
226+
}
227+
return null;
228+
})
229+
.filter(Objects::nonNull)
230+
.map(scalarType::cast)
231+
.collect(toList());
233232
if (result.isEmpty()) {
234233
return null;
235234
}

0 commit comments

Comments
 (0)