2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.sdc.tosca.services;
24 import org.onap.sdc.tosca.datatypes.model.AttributeDefinition;
25 import org.onap.sdc.tosca.datatypes.model.Constraint;
26 import org.onap.sdc.tosca.datatypes.model.PropertyDefinition;
28 import java.util.HashMap;
29 import java.util.List;
31 import java.util.stream.Collectors;
33 public class DataModelCloneUtil {
36 * Clone constraints list.
38 * @param constraints the constraints
41 public static List<Constraint> cloneConstraints(List<Constraint> constraints) {
43 if (constraints == null) {
46 return constraints.stream().map(Constraint::clone).collect(Collectors.toList());
50 * Clone property definitions map.
52 * @param propertyDefinitions the property definitions
55 public static Map<String, PropertyDefinition> clonePropertyDefinitions(
56 Map<String, PropertyDefinition> propertyDefinitions) {
58 if (propertyDefinitions == null) {
61 Map<String, PropertyDefinition> clonedProperties = new HashMap<>();
62 for (String propertyKey : propertyDefinitions.keySet()) {
63 clonedProperties.put(propertyKey, propertyDefinitions.get(propertyKey).clone());
66 return clonedProperties;
70 * Clone attribute definitions map.
72 * @param attributeDefinitions the attribute definitions
75 public static Map<String, AttributeDefinition> cloneAttributeDefinitions(
76 Map<String, AttributeDefinition> attributeDefinitions) {
78 if (attributeDefinitions == null) {
81 Map<String, AttributeDefinition> clonedAttributeDefinitions = new HashMap<>();
82 for (String attributeKey : attributeDefinitions.keySet()) {
83 clonedAttributeDefinitions.put(attributeKey, attributeDefinitions.get(attributeKey).clone());
86 return clonedAttributeDefinitions;
90 * Clone valid source types list.
92 * @param validSourceTypes the valid source types
95 public static List<String> cloneValidSourceTypes(List<String> validSourceTypes) {
97 if (validSourceTypes == null) {
101 return validSourceTypes.stream().collect(Collectors.toList());