Release version 1.13.7
[sdc.git] / catalog-model / src / main / java / org / openecomp / sdc / be / model / ComponentInstInputsMap.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.model;
21
22 import static org.apache.commons.collections.MapUtils.isNotEmpty;
23
24 import java.util.HashMap;
25 import java.util.List;
26 import java.util.Map;
27 import org.apache.commons.lang3.tuple.Pair;
28
29 public class ComponentInstInputsMap {
30
31     private Map<String, List<ComponentInstancePropInput>> componentInstanceInputsMap;
32     private Map<String, List<ComponentInstancePropInput>> componentInstanceProperties;
33     private Map<String, List<ComponentInstancePropInput>> serviceProperties;
34     private Map<String, List<ComponentInstancePropInput>> policyProperties;
35     private Map<String, List<ComponentInstancePropInput>> groupProperties;
36     private Map<String, List<ComponentInstancePropInput>> componentPropertiesToPolicies;
37     private Map<String, List<ComponentInstancePropInput>> componentInstancePropertiesToPolicies;
38
39     public Pair<String, List<ComponentInstancePropInput>> resolvePropertiesToDeclare() {
40         if (isNotEmpty(componentInstanceInputsMap)) {
41             return singleMapEntry(componentInstanceInputsMap);
42         }
43         if (isNotEmpty(componentInstanceProperties)) {
44             return singleMapEntry(componentInstanceProperties);
45         }
46         if (isNotEmpty(policyProperties)) {
47             return singleMapEntry(policyProperties);
48         }
49         if (isNotEmpty(serviceProperties)) {
50             return singleMapEntry(serviceProperties);
51         }
52         if (isNotEmpty(groupProperties)) {
53             return singleMapEntry(groupProperties);
54         }
55         if (isNotEmpty(componentPropertiesToPolicies)) {
56             return singleMapEntry(componentPropertiesToPolicies);
57         }
58         if (isNotEmpty(componentInstancePropertiesToPolicies)) {
59             return singleMapEntry(componentInstancePropertiesToPolicies);
60         }
61         throw new IllegalStateException("there are no properties selected for declaration");
62     }
63
64     private Pair<String, List<ComponentInstancePropInput>> singleMapEntry(Map<String, List<ComponentInstancePropInput>> propertiesMap) {
65         Map.Entry<String, List<ComponentInstancePropInput>> singleEntry = propertiesMap.entrySet().iterator().next();
66         return Pair.of(singleEntry.getKey(), singleEntry.getValue());
67     }
68
69     public Map<String, List<ComponentInstancePropInput>> getComponentInstanceInputsMap() {
70         return componentInstanceInputsMap == null ? new HashMap<>() : componentInstanceInputsMap;
71     }
72
73     public void setComponentInstanceInputsMap(Map<String, List<ComponentInstancePropInput>> componentInstanceInputsMap) {
74         this.componentInstanceInputsMap = componentInstanceInputsMap;
75     }
76
77     public Map<String, List<ComponentInstancePropInput>> getComponentInstanceProperties() {
78         return componentInstanceProperties == null ? new HashMap<>() : componentInstanceProperties;
79     }
80
81     public void setComponentInstancePropInput(Map<String, List<ComponentInstancePropInput>> componentInstanceProperties) {
82         this.componentInstanceProperties = componentInstanceProperties;
83     }
84
85     public Map<String, List<ComponentInstancePropInput>> getPolicyProperties() {
86         return policyProperties == null ? new HashMap<>() : policyProperties;
87     }
88
89     public void setPolicyProperties(Map<String, List<ComponentInstancePropInput>> policyProperties) {
90         this.policyProperties = policyProperties;
91     }
92
93     public Map<String, List<ComponentInstancePropInput>> getServiceProperties() {
94         return serviceProperties;
95     }
96
97     public void setServiceProperties(Map<String, List<ComponentInstancePropInput>> serviceProperties) {
98         this.serviceProperties = serviceProperties;
99     }
100
101     public Map<String, List<ComponentInstancePropInput>> getGroupProperties() {
102         return groupProperties == null ? new HashMap<>() : groupProperties;
103     }
104
105     public void setGroupProperties(Map<String, List<ComponentInstancePropInput>> groupProperties) {
106         this.groupProperties = groupProperties;
107     }
108
109     public Map<String, List<ComponentInstancePropInput>> getComponentPropertiesToPolicies() {
110         return componentPropertiesToPolicies;
111     }
112
113     public void setComponentPropertiesToPolicies(Map<String, List<ComponentInstancePropInput>> componentPropertiesToPolicies) {
114         this.componentPropertiesToPolicies = componentPropertiesToPolicies;
115     }
116
117     public Map<String, List<ComponentInstancePropInput>> getComponentInstancePropertiesToPolicies() {
118         return componentInstancePropertiesToPolicies;
119     }
120
121     public void setComponentInstancePropertiesToPolicies(Map<String, List<ComponentInstancePropInput>> componentInstancePropertiesToPolicies) {
122         this.componentInstancePropertiesToPolicies = componentInstancePropertiesToPolicies;
123     }
124 }