From 6628b98e3ca1d901ff6d4515141e7dfa3746708b Mon Sep 17 00:00:00 2001 From: Andrei Arlou Date: Thu, 29 Aug 2024 03:23:38 +0300 Subject: [PATCH] 3.x: Replace manual casts on pattern with instanceof in HoconConfigParser (#9217) --- .../config/hocon/HoconConfigParser.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/config/hocon/src/main/java/io/helidon/config/hocon/HoconConfigParser.java b/config/hocon/src/main/java/io/helidon/config/hocon/HoconConfigParser.java index 92620c3eaf3..78fbff5c9f8 100644 --- a/config/hocon/src/main/java/io/helidon/config/hocon/HoconConfigParser.java +++ b/config/hocon/src/main/java/io/helidon/config/hocon/HoconConfigParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022 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. @@ -159,10 +159,10 @@ private static ObjectNode fromConfig(ConfigObject config) { ObjectNode.Builder builder = ObjectNode.builder(); config.forEach((unescapedKey, value) -> { String key = io.helidon.config.Config.Key.escapeName(unescapedKey); - if (value instanceof ConfigList) { - builder.addList(key, fromList((ConfigList) value)); - } else if (value instanceof ConfigObject) { - builder.addObject(key, fromConfig((ConfigObject) value)); + if (value instanceof ConfigList configList) { + builder.addList(key, fromList(configList)); + } else if (value instanceof ConfigObject configObject) { + builder.addObject(key, fromConfig(configObject)); } else { try { Object unwrapped = value.unwrapped(); @@ -185,10 +185,10 @@ private static ObjectNode fromConfig(ConfigObject config) { private static ListNode fromList(ConfigList list) { ListNode.Builder builder = ListNode.builder(); list.forEach(value -> { - if (value instanceof ConfigList) { - builder.addList(fromList((ConfigList) value)); - } else if (value instanceof ConfigObject) { - builder.addObject(fromConfig((ConfigObject) value)); + if (value instanceof ConfigList configList) { + builder.addList(fromList(configList)); + } else if (value instanceof ConfigObject configObject) { + builder.addObject(fromConfig(configObject)); } else { try { Object unwrapped = value.unwrapped();