29859cb279bf46d6565a33bece79d8df4f5f560f
[sdc.git] /
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openecomp.sdc.be.datatypes.elements;
18
19 import org.apache.commons.collections.MapUtils;
20 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
21
22 import java.io.Serializable;
23 import java.util.HashMap;
24 import java.util.Map;
25 import java.util.Objects;
26
27 public class InterfaceInstanceDataDefinition extends ToscaDataDefinition implements Serializable {
28   protected Map<String, Object> inputs;
29   protected Map<String, OperationInstance> operations;
30
31   public InterfaceInstanceDataDefinition(
32       InterfaceInstanceDataDefinition inter) {
33     this.toscaPresentation = null;
34     this.inputs = inter.inputs == null? new HashMap():new HashMap<>(inter.inputs);
35     this.operations = new HashMap<>(inter.operations);
36   }
37
38   public InterfaceInstanceDataDefinition(){
39     this.toscaPresentation = null;
40   }
41
42   public Map<String, Object> getInputs() {
43     return this.inputs;
44   }
45
46   public void setInputs(
47       Map<String, Object> inputs) {
48     this.inputs = inputs;
49   }
50
51   public Map<String, OperationInstance> getOperations() {
52     return operations;
53   }
54
55   public void addInstanceOperation(String operationName, OperationInstance operation) {
56     if(MapUtils.isEmpty(this.operations)) {
57       this.operations = new HashMap<>();
58     }
59
60     this.operations.put(operationName, operation);
61   }
62
63   @Override
64   public boolean equals(Object o) {
65     if (this == o) {
66       return true;
67     }
68     if (!(o instanceof InterfaceInstanceDataDefinition)) {
69       return false;
70     }
71     InterfaceInstanceDataDefinition that = (InterfaceInstanceDataDefinition) o;
72     return Objects.equals(inputs, that.inputs);
73   }
74
75   @Override
76   public int hashCode() {
77
78     return Objects.hash(inputs);
79   }
80
81 }