re base code
[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.List;
26 import java.util.Map;
27
28 import static org.apache.commons.collections.MapUtils.isNotEmpty;
29
30 public class ComponentInstInputsMap {
31
32     private Map<String, List<ComponentInstancePropInput>> componentInstanceInputsMap;
33     private Map<String, List<ComponentInstancePropInput>> componentInstanceProperties;
34     private Map<String, List<ComponentInstancePropInput>> policyProperties;
35     private Map<String, List<ComponentInstancePropInput>> groupProperties;
36
37     public Pair<String, List<ComponentInstancePropInput>> resolvePropertiesToDeclare() {
38         if (isNotEmpty(componentInstanceInputsMap)) {
39             return singleMapEntry(componentInstanceInputsMap);
40         }
41         if (isNotEmpty(componentInstanceProperties)) {
42             return singleMapEntry(componentInstanceProperties);
43         }
44         if (isNotEmpty(policyProperties)) {
45             return singleMapEntry(policyProperties);
46         }
47         if (isNotEmpty(groupProperties)) {
48             return singleMapEntry(groupProperties);
49         }
50         throw new IllegalStateException("there are no properties selected for declaration");
51     }
52
53     private Pair<String, List<ComponentInstancePropInput>> singleMapEntry(Map<String, List<ComponentInstancePropInput>> propertiesMap) {
54         Map.Entry<String, List<ComponentInstancePropInput>> singleEntry = propertiesMap.entrySet().iterator().next();
55         return Pair.of(singleEntry.getKey(), singleEntry.getValue());
56     }
57
58     public Map<String, List<ComponentInstancePropInput>> getComponentInstanceInputsMap() {
59         return componentInstanceInputsMap;
60     }
61
62     public void setComponentInstanceInputsMap(Map<String, List<ComponentInstancePropInput>> componentInstanceInputsMap) {
63         this.componentInstanceInputsMap = componentInstanceInputsMap;
64     }
65
66     public Map<String, List<ComponentInstancePropInput>> getComponentInstanceProperties() {
67         return componentInstanceProperties;
68     }
69
70     public void setComponentInstancePropInput(Map<String, List<ComponentInstancePropInput>> componentInstanceProperties) {
71         this.componentInstanceProperties = componentInstanceProperties;
72     }
73
74     public Map<String, List<ComponentInstancePropInput>> getPolicyProperties() {
75         return policyProperties;
76     }
77
78     public void setPolicyProperties(Map<String, List<ComponentInstancePropInput>> policyProperties) {
79         this.policyProperties = policyProperties;
80     }
81
82     public Map<String, List<ComponentInstancePropInput>> getGroupProperties() {
83         return groupProperties;
84     }
85
86     public void setGroupProperties(Map<String, List<ComponentInstancePropInput>> groupProperties) {
87         this.groupProperties = groupProperties;
88     }
89
90
91
92 }