a8207ba8283e70228b4de378718ec5d90c7204de
[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
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     private 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(Map<String, PropertyDefinition> inputs) {
44         this.inputs = inputs;
45     }
46
47     public Map<String, OperationDefinitionType> getOperations() {
48         return operations;
49     }
50
51     public void setOperations(Map<String, OperationDefinitionType> operations) {
52         this.operations = operations;
53     }
54
55     public void addOperation(String operationName, OperationDefinitionType 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 InterfaceDefinitionType)) {
69             return false;
70         }
71
72         InterfaceDefinitionType that = (InterfaceDefinitionType) o;
73
74         if (getType() != null ? !getType().equals(that.getType()) : that.getType() != null) {
75             return false;
76         }
77         if (getInputs() != null ? !getInputs().equals(that.getInputs()) : that.getInputs() != null) {
78             return false;
79         }
80         return getOperations() != null ? getOperations().equals(that.getOperations()) : that.getOperations() == null;
81     }
82
83     @Override
84     public int hashCode() {
85         int result = getType() != null ? getType().hashCode() : 0;
86         result = 31 * result + (getInputs() != null ? getInputs().hashCode() : 0);
87         result = 31 * result + (getOperations() != null ? getOperations().hashCode() : 0);
88         return result;
89     }
90
91     @Override
92     public void addOperation(String operationName, OperationDefinition operationDefinition) {
93         addOperation(operationName, (OperationDefinitionType) operationDefinition);
94     }
95 }