Sync Integ to Master
[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.collections.MapUtils;
24 import org.apache.commons.lang3.tuple.Pair;
25
26 import java.io.Serializable;
27 import java.util.List;
28 import java.util.Map;
29
30 public class ComponentInstInputsMap implements Serializable {
31
32     /**
33      *
34      */
35     private static final long serialVersionUID = 1136631343963488131L;
36
37     private Map<String, List<ComponentInstancePropInput>> componentInstanceInputsMap;
38     private Map<String, List<ComponentInstancePropInput>> componentInstanceProperties;
39     private Map<String, List<ComponentInstancePropInput>> policyProperties;
40
41     public Pair<String, List<ComponentInstancePropInput>> resolvePropertiesToDeclare() {
42         if (!MapUtils.isEmpty(componentInstanceInputsMap)) {
43             return singleMapEntry(componentInstanceInputsMap);
44         }
45         if (!MapUtils.isEmpty(componentInstanceProperties)) {
46             return singleMapEntry(componentInstanceProperties);
47         }
48         if (!MapUtils.isEmpty(policyProperties)) {
49             return singleMapEntry(policyProperties);
50         }
51         throw new IllegalStateException("there are no properties selected for deceleration");
52     }
53
54     private Pair<String, List<ComponentInstancePropInput>> singleMapEntry(Map<String, List<ComponentInstancePropInput>> propertiesMap) {
55         Map.Entry<String, List<ComponentInstancePropInput>> singleEntry = propertiesMap.entrySet().iterator().next();
56         return Pair.of(singleEntry.getKey(), singleEntry.getValue());
57     }
58
59     public Map<String, List<ComponentInstancePropInput>> getComponentInstanceInputsMap() {
60         return componentInstanceInputsMap;
61     }
62
63     public void setComponentInstanceInputsMap(Map<String, List<ComponentInstancePropInput>> componentInstanceInputsMap) {
64         this.componentInstanceInputsMap = componentInstanceInputsMap;
65     }
66
67     public Map<String, List<ComponentInstancePropInput>> getComponentInstanceProperties() {
68         return componentInstanceProperties;
69     }
70
71     public void setComponentInstancePropInput(Map<String, List<ComponentInstancePropInput>> componentInstanceProperties) {
72         this.componentInstanceProperties = componentInstanceProperties;
73     }
74
75     public Map<String, List<ComponentInstancePropInput>> getPolicyProperties() {
76         return policyProperties;
77     }
78
79     public void setPolicyProperties(Map<String, List<ComponentInstancePropInput>> policyProperties) {
80         this.policyProperties = policyProperties;
81     }
82 }