Skip to content

Commit 5c2cca8

Browse files
authored
4.x: Replace manual casts on pattern with instanceof in yaml config modules (helidon-io#9427)
1 parent f192013 commit 5c2cca8

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

config/yaml-mp/src/main/java/io/helidon/config/yaml/mp/YamlMpConfigSource.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -315,10 +315,10 @@ private static void process(Map<String, String> resultMap, String prefix, List y
315315
private static void processNext(Map<String, String> resultMap,
316316
String prefix,
317317
Object value) {
318-
if (value instanceof List) {
319-
process(resultMap, prefix, (List) value);
320-
} else if (value instanceof Map) {
321-
process(resultMap, prefix, (Map) value);
318+
if (value instanceof List listValue) {
319+
process(resultMap, prefix, listValue);
320+
} else if (value instanceof Map mapValue) {
321+
process(resultMap, prefix, mapValue);
322322
} else {
323323
String stringValue = (null == value) ? "" : value.toString();
324324
resultMap.put(prefix, stringValue);

config/yaml/src/main/java/io/helidon/config/yaml/YamlConfigParser.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2024 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -123,10 +123,10 @@ private static ObjectNode fromMap(Map<?, ?> map) {
123123
if (map != null) {
124124
map.forEach((k, v) -> {
125125
String strKey = k.toString();
126-
if (v instanceof List) {
127-
builder.addList(strKey, fromList((List) v));
128-
} else if (v instanceof Map) {
129-
builder.addObject(strKey, fromMap((Map) v));
126+
if (v instanceof List listValue) {
127+
builder.addList(strKey, fromList(listValue));
128+
} else if (v instanceof Map mapValue) {
129+
builder.addObject(strKey, fromMap(mapValue));
130130
} else {
131131
String strValue = v == null ? "" : v.toString();
132132
builder.addValue(strKey, strValue);
@@ -139,10 +139,10 @@ private static ObjectNode fromMap(Map<?, ?> map) {
139139
private static ListNode fromList(List<?> list) {
140140
ListNode.Builder builder = ListNode.builder();
141141
list.forEach(value -> {
142-
if (value instanceof List) {
143-
builder.addList(fromList((List) value));
144-
} else if (value instanceof Map) {
145-
builder.addObject(fromMap((Map) value));
142+
if (value instanceof List listValue) {
143+
builder.addList(fromList(listValue));
144+
} else if (value instanceof Map mapValue) {
145+
builder.addObject(fromMap(mapValue));
146146
} else {
147147
String strValue = value == null ? "" : value.toString();
148148
builder.addValue(strValue);

0 commit comments

Comments
 (0)