745f49dcfa189fe165c089cfb5e05db41396a852
[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 import java.util.Objects;
28
29 public class InterfaceDefinition {
30
31   private String type;
32   private Map<String, PropertyDefinition> inputs;
33   private Map<String, OperationDefinition> operations;
34
35   public String getType() {
36     return type;
37   }
38
39   public void setType(String type) {
40     this.type = type;
41   }
42
43   public Map<String, PropertyDefinition> getInputs() {
44     return inputs;
45   }
46
47   public void setInputs(
48       Map<String, PropertyDefinition> inputs) {
49     this.inputs = inputs;
50   }
51
52   public Map<String, OperationDefinition> getOperations() {
53     return operations;
54   }
55
56   public void addOperation(String operationName, OperationDefinition operationDefinition) {
57     if (MapUtils.isEmpty(this.operations)) {
58       this.operations = new HashMap<>();
59     }
60     this.operations.put(operationName, operationDefinition);
61   }
62
63   @Override
64   public boolean equals(Object o) {
65     if (this == o) {
66       return true;
67     }
68     if (!(o instanceof InterfaceDefinition)) {
69       return false;
70     }
71     InterfaceDefinition that = (InterfaceDefinition) o;
72     return Objects.equals(type, that.type) &&
73         Objects.equals(inputs, that.inputs) &&
74         Objects.equals(operations, that.operations);
75   }
76
77   @Override
78   public int hashCode() {
79     return Objects.hash(type, inputs, operations);
80   }
81 }