22d8e7c6ff0e08495b6b36f40edafe33c0e46656
[sdc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.tosca.datatypes.model;
22
23 import org.apache.commons.collections4.MapUtils;
24
25 import java.util.HashMap;
26 import java.util.Map;
27
28 public class InterfaceType {
29   private String derived_from;
30   private String version;
31   private Map<String, String> metadata;
32   private String description;
33   private Map<String, PropertyDefinition> inputs;
34   private Map<String, OperationDefinition> operations;
35
36   public Map<String, PropertyDefinition> getInputs() {
37     return inputs;
38   }
39
40   public void setInputs(
41       Map<String, PropertyDefinition> inputs) {
42     this.inputs = inputs;
43   }
44
45   public String getDerived_from() {
46     return derived_from;
47   }
48
49   public void setDerived_from(String derived_from) {
50     this.derived_from = derived_from;
51   }
52
53   public String getVersion() {
54     return version;
55   }
56
57   public void setVersion(String version) {
58     this.version = version;
59   }
60
61   public Map<String, String> getMetadata() {
62     return metadata;
63   }
64
65   public void setMetadata(Map<String, String> metadata) {
66     this.metadata = metadata;
67   }
68
69   public String getDescription() {
70     return description;
71   }
72
73   public void setDescription(String description) {
74     this.description = description;
75   }
76
77   public Map<String, OperationDefinition> getOperations() {
78     return operations;
79   }
80
81   public void setOperations(
82       Map<String, OperationDefinition> operations) {
83     this.operations = operations;
84   }
85
86   public void addOperation(String operationName, OperationDefinition operationDefinition) {
87     if(MapUtils.isEmpty(this.operations)){
88       this.operations = new HashMap<>();
89     }
90     this.operations.put(operationName, operationDefinition);
91   }
92
93   @Override
94   public boolean equals(Object o) {
95     if (this == o) {
96       return true;
97     }
98     if (!(o instanceof InterfaceType)) {
99       return false;
100     }
101
102     InterfaceType that = (InterfaceType) o;
103
104     if (getDerived_from() != null ? !getDerived_from().equals(that.getDerived_from())
105         : that.getDerived_from() != null) {
106       return false;
107     }
108     if (getVersion() != null ? !getVersion().equals(that.getVersion())
109         : that.getVersion() != null) {
110       return false;
111     }
112     if (getMetadata() != null ? !getMetadata().equals(that.getMetadata())
113         : that.getMetadata() != null) {
114       return false;
115     }
116     if (getDescription() != null ? !getDescription().equals(that.getDescription())
117         : that.getDescription() != null) {
118       return false;
119     }
120     if (getInputs() != null ? !getInputs().equals(that.getInputs()) : that.getInputs() != null) {
121       return false;
122     }
123     return getOperations() != null ? getOperations().equals(that.getOperations())
124         : that.getOperations() == null;
125   }
126
127   @Override
128   public int hashCode() {
129     int result = getDerived_from() != null ? getDerived_from().hashCode() : 0;
130     result = 31 * result + (getVersion() != null ? getVersion().hashCode() : 0);
131     result = 31 * result + (getMetadata() != null ? getMetadata().hashCode() : 0);
132     result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
133     result = 31 * result + (getInputs() != null ? getInputs().hashCode() : 0);
134     result = 31 * result + (getOperations() != null ? getOperations().hashCode() : 0);
135     return result;
136   }
137 }