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