912e5a7b9986e80d44322d259d57ac7b4d09f571
[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.tosca.datatypes.model;
18
19 import org.apache.commons.collections4.MapUtils;
20
21 import java.util.HashMap;
22 import java.util.Map;
23
24 public class InterfaceDefinitionTemplate extends InterfaceDefinition {
25
26   private Map<String, Object> inputs;
27   private Map<String, OperationDefinitionTemplate> operations;
28
29   public Map<String, Object> getInputs() {
30     return inputs;
31   }
32
33   public void setInputs(
34       Map<String, Object> inputs) {
35     this.inputs = inputs;
36   }
37
38   public Map<String, OperationDefinitionTemplate> getOperations() {
39     return operations;
40   }
41
42   public void setOperations(
43       Map<String, OperationDefinitionTemplate> operations) {
44     this.operations = operations;
45   }
46
47   public void addOperation(String operationName, OperationDefinitionTemplate operation) {
48     if(MapUtils.isEmpty(this.operations)) {
49       this.operations = new HashMap<>();
50     }
51
52     this.operations.put(operationName, operation);
53   }
54
55   @Override
56   public boolean equals(Object o) {
57     if (this == o) {
58       return true;
59     }
60     if (!(o instanceof InterfaceDefinitionTemplate)) {
61       return false;
62     }
63
64     InterfaceDefinitionTemplate that = (InterfaceDefinitionTemplate) o;
65
66     if (getInputs() != null ? !getInputs().equals(that.getInputs()) : that.getInputs() != null) {
67       return false;
68     }
69     return getOperations() != null ? getOperations().equals(that.getOperations())
70         : that.getOperations() == null;
71   }
72
73   @Override
74   public int hashCode() {
75     int result = getInputs() != null ? getInputs().hashCode() : 0;
76     result = 31 * result + (getOperations() != null ? getOperations().hashCode() : 0);
77     return result;
78   }
79
80   @Override
81   public void addOperation(String operationName, OperationDefinition operationDefinition) {
82     addOperation(operationName, (OperationDefinitionTemplate)operationDefinition);
83   }
84 }