2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.be.model;
23 import org.apache.commons.lang3.tuple.Pair;
25 import java.util.List;
28 import static org.apache.commons.collections.MapUtils.isNotEmpty;
30 public class ComponentInstInputsMap {
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;
37 public Pair<String, List<ComponentInstancePropInput>> resolvePropertiesToDeclare() {
38 if (isNotEmpty(componentInstanceInputsMap)) {
39 return singleMapEntry(componentInstanceInputsMap);
41 if (isNotEmpty(componentInstanceProperties)) {
42 return singleMapEntry(componentInstanceProperties);
44 if (isNotEmpty(policyProperties)) {
45 return singleMapEntry(policyProperties);
47 if (isNotEmpty(groupProperties)) {
48 return singleMapEntry(groupProperties);
50 throw new IllegalStateException("there are no properties selected for declaration");
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());
58 public Map<String, List<ComponentInstancePropInput>> getComponentInstanceInputsMap() {
59 return componentInstanceInputsMap;
62 public void setComponentInstanceInputsMap(Map<String, List<ComponentInstancePropInput>> componentInstanceInputsMap) {
63 this.componentInstanceInputsMap = componentInstanceInputsMap;
66 public Map<String, List<ComponentInstancePropInput>> getComponentInstanceProperties() {
67 return componentInstanceProperties;
70 public void setComponentInstancePropInput(Map<String, List<ComponentInstancePropInput>> componentInstanceProperties) {
71 this.componentInstanceProperties = componentInstanceProperties;
74 public Map<String, List<ComponentInstancePropInput>> getPolicyProperties() {
75 return policyProperties;
78 public void setPolicyProperties(Map<String, List<ComponentInstancePropInput>> policyProperties) {
79 this.policyProperties = policyProperties;
82 public Map<String, List<ComponentInstancePropInput>> getGroupProperties() {
83 return groupProperties;
86 public void setGroupProperties(Map<String, List<ComponentInstancePropInput>> groupProperties) {
87 this.groupProperties = groupProperties;