Sync Integ to Master
[sdc.git] / catalog-model / src / main / java / org / openecomp / sdc / be / model / InterfaceDefinition.java
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.be.model;
22
23 import com.fasterxml.jackson.annotation.JsonIgnore;
24 import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
25 import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
26
27 import java.io.Serializable;
28 import java.util.Map;
29 import java.util.stream.Collectors;
30
31 /**
32  * Definition of the operations that can be performed on (instances of) a Node
33  * Type.
34  *
35  * @author esofer
36  */
37 public class InterfaceDefinition extends InterfaceDataDefinition implements IOperationParameter, Serializable {
38
39     /**
40      *
41      */
42     private static final long serialVersionUID = 8220887972866354746L;
43
44
45     private boolean definition;
46
47     public InterfaceDefinition() {
48         super();
49     }
50
51     public InterfaceDefinition(String type, String description, Map<String, Operation> operations) {
52         super(type, description);
53         setOperationsMap(operations);
54     }
55
56     public InterfaceDefinition(InterfaceDataDefinition p) {
57         super(p);
58     }
59
60     @Override
61     public boolean isDefinition() {
62         // TODO Auto-generated method stub
63         return false;
64     }
65
66     public void setDefinition(boolean definition) {
67         this.definition = definition;
68     }
69
70     @JsonIgnore
71     public Map<String, Operation> getOperationsMap() {
72         Map<String, Operation> convertedOperation = getOperations().entrySet()
73                                                                    .stream()
74                                                                    .collect(Collectors.toMap(e -> e.getKey(), e -> new Operation(e
75                                                                            .getValue())));
76         return convertedOperation;
77     }
78
79     @JsonIgnore
80     public void setOperationsMap(Map<String, Operation> operations) {
81         Map<String, OperationDataDefinition> convertedOperation = operations.entrySet()
82                                                                             .stream()
83                                                                             .collect(Collectors.toMap(e -> e.getKey(), e -> new OperationDataDefinition(e
84                                                                                     .getValue())));
85         setOperations(convertedOperation);
86     }
87
88     @Override
89     public String toString() {
90         return "InterfaceDefinition [definition=" + definition + "]";
91     }
92
93 }