summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-model/src/main/java/org')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java47
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperation.java4
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperation.java4
3 files changed, 11 insertions, 44 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java
index 0f36f09ca8..2847367999 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java
@@ -21,11 +21,11 @@
package org.openecomp.sdc.be.model.operations.impl;
import java.lang.reflect.Type;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;
+import java.util.stream.Collectors;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
@@ -118,7 +118,6 @@ public abstract class AbstractOperation {
log.debug("Before adding {} to graph. data = {}", defName, someData);
- @SuppressWarnings("unchecked")
Either<TitanVertex, TitanOperationStatus> eitherSomeData = titanGenericDao.createNode(someData);
log.debug("After adding {} to graph. status is = {}", defName, eitherSomeData);
@@ -284,27 +283,15 @@ public abstract class AbstractOperation {
PropertyTypeValidator validator = type.getValidator();
- boolean isValid = validator.isValid(value, innerType, dataTypes);
- if (true == isValid) {
- return true;
- } else {
- return false;
- }
-
+ return validator.isValid(value, innerType, dataTypes);
}
public boolean isEmptyValue(String value) {
- if (value == null) {
- return true;
- }
- return false;
+ return value == null;
}
public boolean isNullParam(String value) {
- if (value == null) {
- return true;
- }
- return false;
+ return value == null;
}
protected StorageOperationStatus validateAndUpdateComplexValue(IComplexDefaultValue propertyDefinition, String propertyType,
@@ -339,11 +326,7 @@ public abstract class AbstractOperation {
if (jsonElement == null || jsonElement.isJsonNull()) {
value = EMPTY_VALUE;
} else {
- if (jsonElement.toString().isEmpty()) {
- value = "";
- } else {
- value = jsonElement.toString();
- }
+ value = jsonElement.toString();
}
return value;
@@ -376,18 +359,11 @@ public abstract class AbstractOperation {
*/
public List<String> convertConstraintsToString(List<PropertyConstraint> constraints) {
- List<String> result = null;
-
- if (constraints != null && false == constraints.isEmpty()) {
- result = new ArrayList<String>();
- for (PropertyConstraint propertyConstraint : constraints) {
- String constraint = gson.toJson(propertyConstraint);
- result.add(constraint);
- }
-
+ if (constraints == null || constraints.isEmpty()) {
+ return null;
}
- return result;
+ return constraints.stream().map(gson::toJson).collect(Collectors.toList());
}
public List<PropertyConstraint> convertConstraints(List<String> constraints) {
@@ -396,18 +372,13 @@ public abstract class AbstractOperation {
return null;
}
- List<PropertyConstraint> list = new ArrayList<PropertyConstraint>();
Type constraintType = new TypeToken<PropertyConstraint>() {
}.getType();
Gson gson = new GsonBuilder().registerTypeAdapter(constraintType, new PropertyConstraintDeserialiser()).create();
- for (String constraintJson : constraints) {
- PropertyConstraint propertyConstraint = gson.fromJson(constraintJson, constraintType);
- list.add(propertyConstraint);
- }
+ return constraints.stream().map(c -> gson.fromJson(c, PropertyConstraint.class)).collect(Collectors.toList());
- return list;
}
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperation.java
index 2fcdf695be..f9057217a6 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperation.java
@@ -25,7 +25,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.function.Function;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
@@ -155,8 +154,7 @@ public class GroupTypeOperation extends AbstractOperation implements IGroupTypeO
@Override
public Either<GroupTypeDefinition, StorageOperationStatus> getGroupType(String uniqueId, boolean inTransaction) {
- Function<String, Either<GroupTypeDefinition, TitanOperationStatus>> groupTypeGetter = uId -> getGroupTypeByUid(uId);
- return getElementType(groupTypeGetter, uniqueId, inTransaction);
+ return getElementType(this::getGroupTypeByUid, uniqueId, inTransaction);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperation.java
index 796fc8dd34..adea89b9ea 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperation.java
@@ -23,7 +23,6 @@ package org.openecomp.sdc.be.model.operations.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.function.Function;
import javax.annotation.Resource;
@@ -167,8 +166,7 @@ public class PolicyTypeOperation extends AbstractOperation implements IPolicyTyp
@Override
public Either<PolicyTypeDefinition, StorageOperationStatus> getPolicyType(String uniqueId, boolean inTransaction) {
- Function<String, Either<PolicyTypeDefinition, TitanOperationStatus>> policyTypeGetter = uId -> getPolicyTypeByUid(uId);
- return getElementType(policyTypeGetter, uniqueId, inTransaction);
+ return getElementType(this::getPolicyTypeByUid, uniqueId, inTransaction);
}