From d00c73842c6f8e7bb00b29d2fb5dd63b9cde4bfe Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 12 May 2021 13:25:06 -0400 Subject: Fix sonars in policy models Fixed: - a few other "var" cases - use re2j instead of java.util.regex - use correct class for constants - remove unused constants Issue-ID: POLICY-3094 Change-Id: Ifcb2b0623e8df0527f0a279e666d062422978ded Signed-off-by: Jim Hahn --- .../tosca/utils/ToscaServiceTemplateUtils.java | 26 ++++++++-------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'models-tosca/src') diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java index 12e3a9d5a..362653650 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java @@ -21,7 +21,6 @@ package org.onap.policy.models.tosca.utils; -import java.util.Map; import java.util.Map.Entry; import javax.ws.rs.core.Response; import lombok.NonNull; @@ -102,16 +101,15 @@ public class ToscaServiceTemplateUtils { /** * Check entities from a fragment container can be added to an original container. * + * @param The type of TOSCA entity + * @param The type of the JPA TOSCA entity * @param The type of container * * @param compositeContainer the original container * @param fragmentContainer the fragment being added to the original container * @return the composite container with the result */ - @SuppressWarnings("unchecked") - // @formatter:off - private static - , ? extends ToscaEntity>> + private static , S extends PfConceptContainer> S addFragmentEntitites(final S compositeContainer, final S fragmentContainer, final BeanValidationResult result) { @@ -124,14 +122,13 @@ public class ToscaServiceTemplateUtils { } var result2 = new BeanValidationResult("incoming fragment", fragmentContainer); + var originalContainerMap = compositeContainer.getConceptMap(); + var fragmentContainerMap = fragmentContainer.getConceptMap(); - for (Entry> fragmentEntry : fragmentContainer - .getConceptMap().entrySet()) { - JpaToscaEntityType containerEntity = - compositeContainer.getConceptMap().get(fragmentEntry.getKey()); + for (Entry fragmentEntry : fragmentContainerMap.entrySet()) { + J containerEntity = originalContainerMap.get(fragmentEntry.getKey()); if (containerEntity != null && containerEntity.compareTo(fragmentEntry.getValue()) != 0) { - Validated.addResult(result, "entity", fragmentEntry.getKey(), - "does not equal existing entity"); + Validated.addResult(result, "entity", fragmentEntry.getKey(), "does not equal existing entity"); } } @@ -139,13 +136,8 @@ public class ToscaServiceTemplateUtils { result.addResult(result2); } - // This use of a generic map is required to get around typing errors in directly adding the fragment map to the - // original map - @SuppressWarnings("rawtypes") - Map originalContainerMap = compositeContainer.getConceptMap(); - originalContainerMap.putAll(fragmentContainer.getConceptMap()); + originalContainerMap.putAll(fragmentContainerMap); return compositeContainer; } - // @formatter:on } -- cgit 1.2.3-korg