diff options
author | Jim Hahn <jrh3@att.com> | 2021-05-12 13:25:06 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-05-12 13:31:28 -0400 |
commit | d00c73842c6f8e7bb00b29d2fb5dd63b9cde4bfe (patch) | |
tree | f311f6070754db545754ed287455f90261f4c424 /models-tosca | |
parent | 385e119cf90ee2ba83377115c98b3cf60f993158 (diff) |
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 <jrh3@att.com>
Diffstat (limited to 'models-tosca')
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java | 26 |
1 files changed, 9 insertions, 17 deletions
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 <E> The type of TOSCA entity + * @param <J> The type of the JPA TOSCA entity * @param <S> 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 - <S extends PfConceptContainer<? extends JpaToscaEntityType<? extends ToscaEntity>, ? extends ToscaEntity>> + private static <E extends ToscaEntity, J extends JpaToscaEntityType<E>, S extends PfConceptContainer<J, E>> 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<PfConceptKey, ? extends JpaToscaEntityType<? extends ToscaEntity>> fragmentEntry : fragmentContainer - .getConceptMap().entrySet()) { - JpaToscaEntityType<? extends ToscaEntity> containerEntity = - compositeContainer.getConceptMap().get(fragmentEntry.getKey()); + for (Entry<PfConceptKey, J> 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 } |