summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/PolicyTypeImportUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/PolicyTypeImportUtils.java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/PolicyTypeImportUtils.java55
1 files changed, 21 insertions, 34 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/PolicyTypeImportUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/PolicyTypeImportUtils.java
index 4516a226d4..e8ba2d1a2f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/PolicyTypeImportUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/PolicyTypeImportUtils.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,19 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.components.impl.utils;
-import org.openecomp.sdc.be.dao.utils.MapUtil;
-import org.openecomp.sdc.be.model.PolicyTypeDefinition;
-import org.openecomp.sdc.be.model.PropertyDefinition;
+import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
+import static org.springframework.util.CollectionUtils.isEmpty;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-
-import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
-import static org.springframework.util.CollectionUtils.isEmpty;
+import org.openecomp.sdc.be.dao.utils.MapUtil;
+import org.openecomp.sdc.be.model.PolicyTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
public class PolicyTypeImportUtils {
@@ -43,22 +41,15 @@ public class PolicyTypeImportUtils {
if (pt1 == null || pt2 == null) {
return false;
}
- return Objects.equals(pt1.getType(), pt2.getType()) &&
- Objects.equals(pt1.getName(), pt2.getName()) &&
- Objects.equals(pt1.getIcon(), pt2.getIcon()) &&
- Objects.equals(pt1.getVersion(), pt2.getVersion()) &&
- Objects.equals(pt1.getDerivedFrom(), pt2.getDerivedFrom()) &&
- Objects.equals(pt1.getTargets(), pt2.getTargets()) &&
- Objects.equals(pt1.getMetadata(), pt2.getMetadata()) &&
- Objects.equals(pt1.getDescription(), pt2.getDescription()) &&
- PolicyTypeImportUtils.isPolicyPropertiesEquals(pt1.getProperties(), pt2.getProperties());
+ return Objects.equals(pt1.getType(), pt2.getType()) && Objects.equals(pt1.getName(), pt2.getName()) && Objects
+ .equals(pt1.getIcon(), pt2.getIcon()) && Objects.equals(pt1.getVersion(), pt2.getVersion()) && Objects
+ .equals(pt1.getDerivedFrom(), pt2.getDerivedFrom()) && Objects.equals(pt1.getTargets(), pt2.getTargets()) && Objects
+ .equals(pt1.getMetadata(), pt2.getMetadata()) && Objects.equals(pt1.getDescription(), pt2.getDescription()) && PolicyTypeImportUtils
+ .isPolicyPropertiesEquals(pt1.getProperties(), pt2.getProperties());
}
- private static boolean isPolicyPropertiesEquals(List<PropertyDefinition> pt1Props,
- List<PropertyDefinition> pt2Props) {
- if ((pt1Props == pt2Props)
- || pt1Props == null && isEmpty(pt2Props)
- || pt2Props == null && isEmpty(pt1Props)) {
+ private static boolean isPolicyPropertiesEquals(List<PropertyDefinition> pt1Props, List<PropertyDefinition> pt2Props) {
+ if ((pt1Props == pt2Props) || pt1Props == null && isEmpty(pt2Props) || pt2Props == null && isEmpty(pt1Props)) {
return true;
} else if (!isPropertiesListSizesEquals(pt1Props, pt2Props)) {
return false;
@@ -66,8 +57,8 @@ public class PolicyTypeImportUtils {
// The two cases tested by these assertions should have been taken care of by the previous two tests
assert (pt1Props != null && pt2Props != null);
Map<String, PropertyDefinition> pt1PropsByName = MapUtil.toMap(pt1Props, PropertyDefinition::getName);
- long numberOfEqualsProperties = pt2Props.stream()
- .filter(pt2Prop -> policyPropertyEquals(pt1PropsByName.get(pt2Prop.getName()), pt2Prop)).count();
+ long numberOfEqualsProperties = pt2Props.stream().filter(pt2Prop -> policyPropertyEquals(pt1PropsByName.get(pt2Prop.getName()), pt2Prop))
+ .count();
return numberOfEqualsProperties == pt1Props.size();
}
}
@@ -79,17 +70,13 @@ public class PolicyTypeImportUtils {
if (pt1Prop == null || pt2Prop == null) {
return false;
}
- return Objects.equals(pt1Prop.getDefaultValue(), pt2Prop.getDefaultValue()) &&
- Objects.equals(pt1Prop.isDefinition(), pt2Prop.isDefinition()) &&
- Objects.equals(pt1Prop.getDescription(), pt2Prop.getDescription()) &&
- Objects.equals(pt1Prop.isPassword(), pt2Prop.isPassword()) &&
- Objects.equals(pt1Prop.isRequired(), pt2Prop.isRequired()) &&
- Objects.equals(pt1Prop.getSchemaType(), pt2Prop.getSchemaType()) &&
- Objects.equals(pt1Prop.getType(), pt2Prop.getType());
+ return Objects.equals(pt1Prop.getDefaultValue(), pt2Prop.getDefaultValue()) && Objects.equals(pt1Prop.isDefinition(), pt2Prop.isDefinition())
+ && Objects.equals(pt1Prop.getDescription(), pt2Prop.getDescription()) && Objects.equals(pt1Prop.isPassword(), pt2Prop.isPassword())
+ && Objects.equals(pt1Prop.isRequired(), pt2Prop.isRequired()) && Objects.equals(pt1Prop.getSchemaType(), pt2Prop.getSchemaType())
+ && Objects.equals(pt1Prop.getType(), pt2Prop.getType());
}
private static boolean isPropertiesListSizesEquals(List<PropertyDefinition> pt1Props, List<PropertyDefinition> pt2Props) {
- return (isEmpty(pt1Props) && isEmpty(pt2Props))
- || (isNotEmpty(pt1Props) && isNotEmpty(pt2Props) && pt1Props.size() == pt2Props.size());
+ return (isEmpty(pt1Props) && isEmpty(pt2Props)) || (isNotEmpty(pt1Props) && isNotEmpty(pt2Props) && pt1Props.size() == pt2Props.size());
}
}