summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org
diff options
context:
space:
mode:
authortalio <tali.orenbach@amdocs.com>2018-03-15 14:46:20 +0200
committertalio <tali.orenbach@amdocs.com>2018-03-15 16:54:28 +0200
commit8b6be264a6f4b658632b7e263737eaae92e337aa (patch)
tree6b45776c5c577c77d5da25e4764b854f2a5cfc2c /openecomp-be/lib/openecomp-tosca-lib/src/main/java/org
parent704247137bdba671e55c0ebde7e226fff422b608 (diff)
Interface definition
Add separate Interface definition for node type and node template Change-Id: I0c4446227dd096959158fd4a4741cb5aa043e495 Issue-ID: SDC-1043 Signed-off-by: talio <tali.orenbach@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/main/java/org')
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java29
1 files changed, 14 insertions, 15 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java
index aef23be03f..6b1046bb45 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java
@@ -40,6 +40,7 @@ import org.openecomp.sdc.tosca.datatypes.model.EntrySchema;
import org.openecomp.sdc.tosca.datatypes.model.GroupDefinition;
import org.openecomp.sdc.tosca.datatypes.model.Import;
import org.openecomp.sdc.tosca.datatypes.model.InterfaceDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.InterfaceDefinitionType;
import org.openecomp.sdc.tosca.datatypes.model.InterfaceType;
import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
import org.openecomp.sdc.tosca.datatypes.model.NodeType;
@@ -1212,33 +1213,32 @@ public class DataModelUtil {
return convertedInterfaceTypes;
}
- public static Optional<InterfaceDefinition> convertObjToInterfaceDefinition(
- String interfaceId, Object interfaceObj)
- throws CoreException {
+ public static <T extends InterfaceDefinition> Optional<T>
+ convertObjToInterfaceDefinition(
+ String interfaceId, Object interfaceObj, Class<T> interfaceClass) {
try {
- Optional<InterfaceDefinition> interfaceDefinition =
- CommonUtil.createObjectUsingSetters(interfaceObj, InterfaceDefinition.class);
- interfaceDefinition.ifPresent(interfaceDefinition1 -> updateInterfaceDefinitionOperations(
+ Optional<T> interfaceDefinition =
+ CommonUtil.createObjectUsingSetters(interfaceObj, interfaceClass);
+ interfaceDefinition.ifPresent(interfaceDefinitionType1 -> updateInterfaceDefinitionOperations(
CommonUtil.getObjectAsMap(interfaceObj),
- interfaceDefinition1));
+ interfaceDefinitionType1));
return interfaceDefinition;
} catch (Exception ex) {
throw new CoreException(
- new CreateInterfaceObjectErrorBuilder(InterfaceDefinition.class.getName(), interfaceId,
+ new CreateInterfaceObjectErrorBuilder(InterfaceDefinitionType.class.getName(), interfaceId,
ex.getMessage()).build());
}
}
public static Optional<Object> convertInterfaceDefinitionToObj(
- InterfaceDefinition interfaceDefinition) {
- return converInetrfaceToToscaInterfaceObj(interfaceDefinition);
+ InterfaceDefinitionType interfaceDefinitionType) {
+ return converInetrfaceToToscaInterfaceObj(interfaceDefinitionType);
}
public static Optional<InterfaceType> convertObjToInterfaceType(String interfaceId,
- Object interfaceObj)
- throws CoreException {
+ Object interfaceObj) {
try {
Optional<InterfaceType> interfaceType =
CommonUtil.createObjectUsingSetters(interfaceObj, InterfaceType.class);
@@ -1289,8 +1289,7 @@ public class DataModelUtil {
private static Optional<OperationDefinition> createOperation(String propertyName,
Object operationCandidate,
- Set<String> fieldNames)
- throws CoreException {
+ Set<String> fieldNames) {
if (!fieldNames.contains(propertyName)) {
try {
return CommonUtil.createObjectUsingSetters(operationCandidate, OperationDefinition.class);
@@ -1306,7 +1305,7 @@ public class DataModelUtil {
private static void updateInterfaceDefinitionOperations(Map<String, Object> interfaceAsMap,
InterfaceDefinition interfaceDefinition) {
- Set<String> fieldNames = CommonUtil.getClassFieldNames(InterfaceDefinition.class);
+ Set<String> fieldNames = CommonUtil.getClassFieldNames(InterfaceDefinitionType.class);
for (Map.Entry<String, Object> entry : interfaceAsMap.entrySet()) {
Optional<OperationDefinition> operationDefinition =