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.collections.MapUtils;
24 import org.apache.commons.lang3.tuple.Pair;
26 import java.io.Serializable;
27 import java.util.List;
30 public class ComponentInstInputsMap implements Serializable {
35 private static final long serialVersionUID = 1136631343963488131L;
37 private Map<String, List<ComponentInstancePropInput>> componentInstanceInputsMap;
38 private Map<String, List<ComponentInstancePropInput>> componentInstanceProperties;
39 private Map<String, List<ComponentInstancePropInput>> policyProperties;
41 public Pair<String, List<ComponentInstancePropInput>> resolvePropertiesToDeclare() {
42 if (!MapUtils.isEmpty(componentInstanceInputsMap)) {
43 return singleMapEntry(componentInstanceInputsMap);
45 if (!MapUtils.isEmpty(componentInstanceProperties)) {
46 return singleMapEntry(componentInstanceProperties);
48 if (!MapUtils.isEmpty(policyProperties)) {
49 return singleMapEntry(policyProperties);
51 throw new IllegalStateException("there are no properties selected for deceleration");
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());
59 public Map<String, List<ComponentInstancePropInput>> getComponentInstanceInputsMap() {
60 return componentInstanceInputsMap;
63 public void setComponentInstanceInputsMap(Map<String, List<ComponentInstancePropInput>> componentInstanceInputsMap) {
64 this.componentInstanceInputsMap = componentInstanceInputsMap;
67 public Map<String, List<ComponentInstancePropInput>> getComponentInstanceProperties() {
68 return componentInstanceProperties;
71 public void setComponentInstancePropInput(Map<String, List<ComponentInstancePropInput>> componentInstanceProperties) {
72 this.componentInstanceProperties = componentInstanceProperties;
75 public Map<String, List<ComponentInstancePropInput>> getPolicyProperties() {
76 return policyProperties;
79 public void setPolicyProperties(Map<String, List<ComponentInstancePropInput>> policyProperties) {
80 this.policyProperties = policyProperties;