diff options
Diffstat (limited to 'utils/src/main/java/org/onap/policy/common/utils/properties/PropertyObjectUtils.java')
-rw-r--r-- | utils/src/main/java/org/onap/policy/common/utils/properties/PropertyObjectUtils.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/utils/src/main/java/org/onap/policy/common/utils/properties/PropertyObjectUtils.java b/utils/src/main/java/org/onap/policy/common/utils/properties/PropertyObjectUtils.java index 996f1b87..07346927 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/properties/PropertyObjectUtils.java +++ b/utils/src/main/java/org/onap/policy/common/utils/properties/PropertyObjectUtils.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.regex.Matcher; import java.util.regex.Pattern; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,6 +35,7 @@ public class PropertyObjectUtils { public static final Logger logger = LoggerFactory.getLogger(PropertyObjectUtils.class); private static final Pattern NAME_PAT = Pattern.compile("\\[(\\d{1,3})\\]$"); + private static final Pattern DOT_PAT = Pattern.compile("[.]"); private PropertyObjectUtils() { // do nothing @@ -58,7 +58,7 @@ public class PropertyObjectUtils { for (String name : properties.stringPropertyNames()) { if (name.startsWith(dottedPrefix)) { - String[] components = name.substring(pfxlen).split("[.]"); + String[] components = DOT_PAT.split(name.substring(pfxlen)); setProperty(map, components, properties.getProperty(name)); } } @@ -79,13 +79,13 @@ public class PropertyObjectUtils { final int lastComp = names.length - 1; // process all but the final component - for (int comp = 0; comp < lastComp; ++comp) { + for (var comp = 0; comp < lastComp; ++comp) { node = getNode(node, names[comp]); } // process the final component String name = names[lastComp]; - Matcher matcher = NAME_PAT.matcher(name); + var matcher = NAME_PAT.matcher(name); if (!matcher.find()) { // no subscript @@ -95,7 +95,7 @@ public class PropertyObjectUtils { // subscripted List<Object> array = getArray(node, name.substring(0, matcher.start())); - int index = Integer.parseInt(matcher.group(1)); + var index = Integer.parseInt(matcher.group(1)); expand(array, index); array.set(index, value); } @@ -109,7 +109,7 @@ public class PropertyObjectUtils { */ @SuppressWarnings("unchecked") private static Map<String, Object> getNode(Map<String, Object> map, String name) { - Matcher matcher = NAME_PAT.matcher(name); + var matcher = NAME_PAT.matcher(name); if (!matcher.find()) { // no subscript @@ -118,7 +118,7 @@ public class PropertyObjectUtils { // subscripted List<Object> array = getArray(map, name.substring(0, matcher.start())); - int index = Integer.parseInt(matcher.group(1)); + var index = Integer.parseInt(matcher.group(1)); expand(array, index); Object item = array.get(index); |