Make Service base type optional
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / tosca / model / ToscaTopolgyTemplate.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20 package org.openecomp.sdc.be.tosca.model;
21
22 import java.util.HashMap;
23 import java.util.Map;
24 import lombok.Getter;
25 import lombok.Setter;
26 import org.apache.commons.collections.MapUtils;
27
28 @Getter
29 public class ToscaTopolgyTemplate {
30
31     @Setter
32     private Map<String, ToscaProperty> inputs;
33     @Setter
34     private Map<String, ToscaProperty> outputs;
35     @Setter
36     private Map<String, ToscaNodeTemplate> node_templates;
37     private Map<String, ToscaGroupTemplate> groups;
38     private Map<String, ToscaPolicyTemplate> policies;
39     @Setter
40     private SubstitutionMapping substitution_mappings;
41     @Setter
42     private Map<String, ToscaRelationshipTemplate> relationshipTemplates;
43
44     public void addGroups(Map<String, ToscaGroupTemplate> groups) {
45         if (this.groups == null) {
46             this.groups = new HashMap<>();
47         }
48         this.groups.putAll(groups);
49     }
50
51     public void addPolicies(Map<String, ToscaPolicyTemplate> policiesMap) {
52         if (this.policies == null) {
53             this.policies = new HashMap<>();
54         }
55         this.policies.putAll(policiesMap);
56     }
57
58     public boolean isEmpty() {
59         return substitution_mappings == null &&
60             MapUtils.isEmpty(inputs) &&
61             MapUtils.isEmpty(outputs) &&
62             MapUtils.isEmpty(node_templates) &&
63             MapUtils.isEmpty(groups) &&
64             MapUtils.isEmpty(policies) &&
65             MapUtils.isEmpty(relationshipTemplates);
66     }
67 }