ActivitySpec - Correcting logger messages
[sdc.git] / common / openecomp-tosca-datatype / src / main / java / org / openecomp / sdc / tosca / datatypes / model / InterfaceDefinitionTemplate.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 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 import java.util.Objects;
24
25 public class InterfaceDefinitionTemplate extends InterfaceDefinition {
26
27   private Map<String, Object> inputs;
28   private Map<String, OperationDefinitionTemplate> operations;
29
30   public Map<String, Object> getInputs() {
31     return inputs;
32   }
33
34   public void setInputs(
35       Map<String, Object> inputs) {
36     this.inputs = inputs;
37   }
38
39   public Map<String, OperationDefinitionTemplate> getOperations() {
40     return operations;
41   }
42
43   public void addOperation(String operationName, OperationDefinitionTemplate operation) {
44     if(MapUtils.isEmpty(this.operations)) {
45       this.operations = new HashMap<>();
46     }
47
48     this.operations.put(operationName, operation);
49   }
50
51   @Override
52   public boolean equals(Object o) {
53     if (this == o) {
54       return true;
55     }
56     if (!(o instanceof InterfaceDefinitionTemplate)) {
57       return false;
58     }
59     InterfaceDefinitionTemplate that = (InterfaceDefinitionTemplate) o;
60     return Objects.equals(inputs, that.inputs) &&
61         Objects.equals(operations, that.operations);
62   }
63
64   @Override
65   public int hashCode() {
66
67     return Objects.hash(inputs, operations);
68   }
69
70   @Override
71   public void addOperation(String operationName, OperationDefinition operationDefinition) {
72     addOperation(operationName, (OperationDefinitionTemplate)operationDefinition);
73   }
74 }