Skip to content

Commit

Permalink
4.x: Replace manual casts on pattern with instanceof in yaml config m…
Browse files Browse the repository at this point in the history
…odules (#9427)
  • Loading branch information
Captain1653 authored Nov 27, 2024
1 parent f192013 commit 5c2cca8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -315,10 +315,10 @@ private static void process(Map<String, String> resultMap, String prefix, List y
private static void processNext(Map<String, String> resultMap,
String prefix,
Object value) {
if (value instanceof List) {
process(resultMap, prefix, (List) value);
} else if (value instanceof Map) {
process(resultMap, prefix, (Map) value);
if (value instanceof List listValue) {
process(resultMap, prefix, listValue);
} else if (value instanceof Map mapValue) {
process(resultMap, prefix, mapValue);
} else {
String stringValue = (null == value) ? "" : value.toString();
resultMap.put(prefix, stringValue);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
* Copyright (c) 2020, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -123,10 +123,10 @@ private static ObjectNode fromMap(Map<?, ?> map) {
if (map != null) {
map.forEach((k, v) -> {
String strKey = k.toString();
if (v instanceof List) {
builder.addList(strKey, fromList((List) v));
} else if (v instanceof Map) {
builder.addObject(strKey, fromMap((Map) v));
if (v instanceof List listValue) {
builder.addList(strKey, fromList(listValue));
} else if (v instanceof Map mapValue) {
builder.addObject(strKey, fromMap(mapValue));
} else {
String strValue = v == null ? "" : v.toString();
builder.addValue(strKey, strValue);
Expand All @@ -139,10 +139,10 @@ private static ObjectNode fromMap(Map<?, ?> map) {
private static ListNode fromList(List<?> list) {
ListNode.Builder builder = ListNode.builder();
list.forEach(value -> {
if (value instanceof List) {
builder.addList(fromList((List) value));
} else if (value instanceof Map) {
builder.addObject(fromMap((Map) value));
if (value instanceof List listValue) {
builder.addList(fromList(listValue));
} else if (value instanceof Map mapValue) {
builder.addObject(fromMap(mapValue));
} else {
String strValue = value == null ? "" : value.toString();
builder.addValue(strValue);
Expand Down

0 comments on commit 5c2cca8

Please sign in to comment.