Rename packages from openecomp to onap.
[sdc.git] / common / onap-tosca-datatype / src / main / java / org / onap / sdc / tosca / datatypes / model / InterfaceDefinitionType.java
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
18 package org.onap.sdc.tosca.datatypes.model;
19
20 import org.apache.commons.collections4.MapUtils;
21
22 import java.util.HashMap;
23 import java.util.Map;
24
25 public class InterfaceDefinitionType extends InterfaceDefinition {
26
27   private String type;
28   private Map<String, PropertyDefinition> inputs;
29   protected Map<String, OperationDefinitionType> operations;
30
31   public String getType() {
32     return type;
33   }
34
35   public void setType(String type) {
36     this.type = type;
37   }
38
39   public Map<String, PropertyDefinition> getInputs() {
40     return inputs;
41   }
42
43   public void setInputs(
44       Map<String, PropertyDefinition> inputs) {
45     this.inputs = inputs;
46   }
47
48   public Map<String, OperationDefinitionType> getOperations() {
49     return operations;
50   }
51
52   public void setOperations(
53       Map<String, OperationDefinitionType> operations) {
54     this.operations = operations;
55   }
56
57   public void addOperation(String operationName, OperationDefinitionType operation) {
58     if(MapUtils.isEmpty(this.operations)) {
59       this.operations = new HashMap<>();
60     }
61
62     this.operations.put(operationName, operation);
63   }
64
65   @Override
66   public boolean equals(Object o) {
67     if (this == o) {
68       return true;
69     }
70     if (!(o instanceof InterfaceDefinitionType)) {
71       return false;
72     }
73
74     InterfaceDefinitionType that = (InterfaceDefinitionType) o;
75
76     if (getType() != null ? !getType().equals(that.getType()) : that.getType() != null) {
77       return false;
78     }
79     if (getInputs() != null ? !getInputs().equals(that.getInputs()) : that.getInputs() != null) {
80       return false;
81     }
82     return getOperations() != null ? getOperations().equals(that.getOperations())
83         : that.getOperations() == null;
84   }
85
86   @Override
87   public int hashCode() {
88     int result = getType() != null ? getType().hashCode() : 0;
89     result = 31 * result + (getInputs() != null ? getInputs().hashCode() : 0);
90     result = 31 * result + (getOperations() != null ? getOperations().hashCode() : 0);
91     return result;
92   }
93
94   @Override
95   public void addOperation(String operationName, OperationDefinition operationDefinition) {
96     addOperation(operationName, (OperationDefinitionType)operationDefinition);
97   }
98 }