From 6b6eb52ef3111142ba2dc9afb85cdd48dc0454ca Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 10 May 2021 11:39:27 -0400 Subject: Fix sonars in policy models Fixed: - use "var" Issue-ID: POLICY-3094 Change-Id: Id5ea7ab049c2018744afa75a55d44e47f216d5bc Signed-off-by: Jim Hahn --- .../concepts/ToscaConceptIdentifier.java | 2 +- .../provider/AuthorativeToscaProvider.java | 10 +++---- .../concepts/JpaToscaCapabilityAssignment.java | 2 +- .../simple/concepts/JpaToscaConstraintLogical.java | 3 +- .../concepts/JpaToscaConstraintValidValues.java | 4 +-- .../tosca/simple/concepts/JpaToscaDataType.java | 2 +- .../simple/concepts/JpaToscaNodeTemplate.java | 2 +- .../tosca/simple/concepts/JpaToscaNodeType.java | 2 +- .../tosca/simple/concepts/JpaToscaParameter.java | 4 +-- .../tosca/simple/concepts/JpaToscaPolicy.java | 2 +- .../tosca/simple/concepts/JpaToscaPolicyType.java | 2 +- .../tosca/simple/concepts/JpaToscaProperty.java | 2 +- .../tosca/simple/concepts/JpaToscaRequirement.java | 2 +- .../simple/concepts/JpaToscaSchemaDefinition.java | 2 +- .../simple/concepts/JpaToscaServiceTemplate.java | 2 +- .../simple/concepts/JpaToscaTopologyTemplate.java | 4 +-- .../concepts/JpaToscaWithToscaProperties.java | 4 +-- .../JpaToscaWithTypeAndStringProperties.java | 2 +- .../tosca/simple/provider/SimpleToscaProvider.java | 32 +++++++++++----------- .../tosca/utils/ToscaServiceTemplateUtils.java | 8 +++--- .../onap/policy/models/tosca/utils/ToscaUtils.java | 3 +- 21 files changed, 48 insertions(+), 48 deletions(-) (limited to 'models-tosca/src') diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java index 9033c8fa0..a24341458 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java @@ -57,7 +57,7 @@ public class ToscaConceptIdentifier extends ToscaNameVersion * @return the validation result */ public ValidationResult validatePapRest() { - BeanValidationResult result = new BeanValidationResult("identifier", this); + var result = new BeanValidationResult("identifier", this); result.validateNotNull("name", getName()); result.validateNotNull("version", getVersion()); diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java index c43aadf0f..8171b7d78 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications 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. @@ -243,7 +243,7 @@ public class AuthorativeToscaProvider { synchronized (providerLockObject) { LOGGER.debug("->getFilteredPolicyTypes: filter={}", filter); - SimpleToscaProvider simpleToscaProvider = new SimpleToscaProvider(); + var simpleToscaProvider = new SimpleToscaProvider(); final JpaToscaServiceTemplate dbServiceTemplate = simpleToscaProvider.getPolicyTypes(dao, null, null); @@ -255,7 +255,7 @@ public class AuthorativeToscaProvider { "policy types for filter " + filter.toString() + " do not exist"); } - JpaToscaServiceTemplate filteredServiceTemplate = new JpaToscaServiceTemplate(); + var filteredServiceTemplate = new JpaToscaServiceTemplate(); for (ToscaPolicyType policyType : filteredPolicyTypes) { JpaToscaServiceTemplate cascadedServiceTemplate = simpleToscaProvider @@ -430,7 +430,7 @@ public class AuthorativeToscaProvider { String version = ToscaTypedEntityFilter.LATEST_VERSION.equals(filter.getVersion()) ? null : filter.getVersion(); - SimpleToscaProvider simpleToscaProvider = new SimpleToscaProvider(); + var simpleToscaProvider = new SimpleToscaProvider(); final JpaToscaServiceTemplate dbServiceTemplate = simpleToscaProvider.getPolicies(dao, filter.getName(), version); @@ -443,7 +443,7 @@ public class AuthorativeToscaProvider { "policies for filter " + filter.toString() + " do not exist"); } - JpaToscaServiceTemplate filteredServiceTemplate = new JpaToscaServiceTemplate(); + var filteredServiceTemplate = new JpaToscaServiceTemplate(); for (ToscaPolicy policy : filteredPolicies) { JpaToscaServiceTemplate cascadedServiceTemplate = simpleToscaProvider diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignment.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignment.java index 76508dabe..3e0ec281b 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignment.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignment.java @@ -104,7 +104,7 @@ public class JpaToscaCapabilityAssignment extends JpaToscaWithTypeAndStringPrope @Override public ToscaCapabilityAssignment toAuthorative() { - ToscaCapabilityAssignment toscaCapabilityAssignment = new ToscaCapabilityAssignment(); + var toscaCapabilityAssignment = new ToscaCapabilityAssignment(); super.setToscaEntity(toscaCapabilityAssignment); super.toAuthorative(); diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java index 73546f681..e8d16a705 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 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. @@ -70,7 +71,7 @@ public class JpaToscaConstraintLogical extends JpaToscaConstraint { @Override public ToscaConstraint toAuthorative() { - ToscaConstraint toscaConstraint = new ToscaConstraint(); + var toscaConstraint = new ToscaConstraint(); if (operation == null) { return null; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintValidValues.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintValidValues.java index 9941bc9fd..b5c2d10e5 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintValidValues.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintValidValues.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -68,7 +68,7 @@ public class JpaToscaConstraintValidValues extends JpaToscaConstraint { @Override public ToscaConstraint toAuthorative() { - ToscaConstraint toscaConstraint = new ToscaConstraint(); + var toscaConstraint = new ToscaConstraint(); toscaConstraint.setValidValues(validValues); diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataType.java index bcbf40086..c086c535a 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataType.java @@ -90,7 +90,7 @@ public class JpaToscaDataType extends JpaToscaWithToscaProperties @Override public ToscaDataType toAuthorative() { - ToscaDataType toscaDataType = new ToscaDataType(); + var toscaDataType = new ToscaDataType(); super.setToscaEntity(toscaDataType); super.toAuthorative(); diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java index f6cfc1258..bd1dfd4d5 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java @@ -126,7 +126,7 @@ public class JpaToscaNodeTemplate extends JpaToscaWithTypeAndStringProperties @Override public ToscaNodeType toAuthorative() { - ToscaNodeType toscaNodeType = new ToscaNodeType(); + var toscaNodeType = new ToscaNodeType(); super.setToscaEntity(toscaNodeType); super.toAuthorative(); diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.java index 0348bb1d4..9b023dcba 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix Foundation. - * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020-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. @@ -116,7 +116,7 @@ public class JpaToscaParameter extends PfConcept implements PfAuthorative(); for (Map.Entry toscaInputEntry : toscaTopologyTemplate.getInputs().entrySet()) { - JpaToscaParameter jpaInput = new JpaToscaParameter(toscaInputEntry.getValue()); + var jpaInput = new JpaToscaParameter(toscaInputEntry.getValue()); jpaInput.setKey(new PfReferenceKey(getKey(), toscaInputEntry.getKey())); inputs.put(toscaInputEntry.getKey(), jpaInput); } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaProperties.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaProperties.java index 33e4e86b4..510287581 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaProperties.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaProperties.java @@ -107,7 +107,7 @@ public abstract class JpaToscaWithToscaProperties(); for (Entry toscaPropertyEntry : authorativeConcept.getProperties().entrySet()) { - JpaToscaProperty jpaProperty = new JpaToscaProperty(toscaPropertyEntry.getValue()); + var jpaProperty = new JpaToscaProperty(toscaPropertyEntry.getValue()); jpaProperty.setKey(new PfReferenceKey(getKey(), toscaPropertyEntry.getKey())); properties.put(toscaPropertyEntry.getKey(), jpaProperty); } @@ -116,7 +116,7 @@ public abstract class JpaToscaWithToscaProperties> ancestorList = ToscaUtils @@ -480,7 +480,7 @@ public class SimpleToscaProvider { new SimpleToscaServiceTemplateProvider().write(dao, serviceTemplate); dao.delete(policyType4Deletion); - JpaToscaServiceTemplate deletedServiceTemplate = new JpaToscaServiceTemplate(); + var deletedServiceTemplate = new JpaToscaServiceTemplate(); deletedServiceTemplate.setPolicyTypes(new JpaToscaPolicyTypes()); deletedServiceTemplate.getPolicyTypes().getConceptMap().put(policyTypeKey, policyType4Deletion); @@ -526,7 +526,7 @@ public class SimpleToscaProvider { public JpaToscaServiceTemplate getCascadedPolicies(final JpaToscaServiceTemplate dbServiceTemplate, final String name, final String version) throws PfModelException { - JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate(dbServiceTemplate); + var serviceTemplate = new JpaToscaServiceTemplate(dbServiceTemplate); serviceTemplate.setDataTypes(new JpaToscaDataTypes()); serviceTemplate.setPolicyTypes(new JpaToscaPolicyTypes()); @@ -537,7 +537,7 @@ public class SimpleToscaProvider { "policies for " + name + ":" + version + DO_NOT_EXIST); } - JpaToscaServiceTemplate returnServiceTemplate = new JpaToscaServiceTemplate(serviceTemplate); + var returnServiceTemplate = new JpaToscaServiceTemplate(serviceTemplate); returnServiceTemplate.getTopologyTemplate().setPolicies(new JpaToscaPolicies()); for (JpaToscaPolicy policy : serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().values()) { @@ -592,7 +592,7 @@ public class SimpleToscaProvider { } // Return the created policy types - JpaToscaPolicies returnPolicies = new JpaToscaPolicies(); + var returnPolicies = new JpaToscaPolicies(); returnPolicies.setKey(serviceTemplate.getTopologyTemplate().getPolicies().getKey()); for (PfConceptKey policyKey : serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().keySet()) { @@ -632,7 +632,7 @@ public class SimpleToscaProvider { new SimpleToscaServiceTemplateProvider().write(dao, serviceTemplate); dao.delete(policy4Deletion); - JpaToscaServiceTemplate deletedServiceTemplate = new JpaToscaServiceTemplate(); + var deletedServiceTemplate = new JpaToscaServiceTemplate(); deletedServiceTemplate.setTopologyTemplate(new JpaToscaTopologyTemplate()); deletedServiceTemplate.getTopologyTemplate().setPolicies(new JpaToscaPolicies()); deletedServiceTemplate.getTopologyTemplate().getPolicies().getConceptMap().put(policyKey, policy4Deletion); @@ -685,7 +685,7 @@ public class SimpleToscaProvider { } // Create a filter to get the latest version of the policy type - PfConceptFilter pfConceptFilter = PfConceptFilter.builder().version(PfConceptFilter.LATEST_VERSION).build(); + var pfConceptFilter = PfConceptFilter.builder().version(PfConceptFilter.LATEST_VERSION).build(); // FIlter the returned policy type list List policyTypeKeyList = new ArrayList<>(jpaPolicyTypeList); 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 fe5299337..12e3a9d5a 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 @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix Foundation. - * Modifications Copyright (C) 2020 AT&T + * Modifications Copyright (C) 2020-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. @@ -57,7 +57,7 @@ public class ToscaServiceTemplateUtils { public static JpaToscaServiceTemplate addFragment(@NonNull final JpaToscaServiceTemplate originalTemplate, @NonNull final JpaToscaServiceTemplate fragmentTemplate) { - BeanValidationResult result = new BeanValidationResult("incoming fragment", fragmentTemplate); + var result = new BeanValidationResult("incoming fragment", fragmentTemplate); if (originalTemplate.compareToWithoutEntities(fragmentTemplate) != 0) { Validated.addResult(result, "service template", @@ -65,7 +65,7 @@ public class ToscaServiceTemplateUtils { "does not equal existing service template"); } - JpaToscaServiceTemplate compositeTemplate = new JpaToscaServiceTemplate(originalTemplate); + var compositeTemplate = new JpaToscaServiceTemplate(originalTemplate); compositeTemplate.setDataTypes( addFragmentEntitites(compositeTemplate.getDataTypes(), fragmentTemplate.getDataTypes(), result)); @@ -123,7 +123,7 @@ public class ToscaServiceTemplateUtils { return compositeContainer; } - BeanValidationResult result2 = new BeanValidationResult("incoming fragment", fragmentContainer); + var result2 = new BeanValidationResult("incoming fragment", fragmentContainer); for (Entry> fragmentEntry : fragmentContainer .getConceptMap().entrySet()) { diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java index 2fa2a557a..450b589c5 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java @@ -29,7 +29,6 @@ import javax.ws.rs.core.Response; import lombok.NonNull; import org.apache.commons.collections4.CollectionUtils; import org.onap.policy.common.parameters.BeanValidationResult; -import org.onap.policy.common.parameters.ObjectValidationResult; import org.onap.policy.common.parameters.ValidationStatus; import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfConceptContainer; @@ -259,7 +258,7 @@ public final class ToscaUtils { @NonNull final PfConceptContainer entityTypes, final String entityName, final String entityVersion) { - BeanValidationResult result = new BeanValidationResult("entity", entityName); + var result = new BeanValidationResult("entity", entityName); @SuppressWarnings("unchecked") Set> filteredEntitySet = -- cgit 1.2.3-korg