Added oparent to sdc main
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / elements / ForwardingPathElementDataDefinition.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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.datatypes.elements;
22
23 import com.fasterxml.jackson.annotation.JsonCreator;
24 import com.google.common.base.MoreObjects;
25 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
26 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
27
28 import java.util.Objects;
29
30 public class ForwardingPathElementDataDefinition extends ToscaDataDefinition {
31     @JsonCreator
32     public ForwardingPathElementDataDefinition() {
33         super();
34     }
35
36     public ForwardingPathElementDataDefinition(String fromNode, String toNode, String fromCPName, String toCPName , String fromCPOriginId, String toCPOriginId) {
37         super();
38         setFromNode(fromNode);
39         setToNode(toNode);
40         setFromCP(fromCPName);
41         setToCP(toCPName);
42         setFromCPOriginId(fromCPOriginId);
43         setToCPOriginId(toCPOriginId);
44     }
45
46     public ForwardingPathElementDataDefinition(ForwardingPathElementDataDefinition pathElement) {
47         super();
48         setFromNode(pathElement.getFromNode());
49         setToNode(pathElement.getToNode());
50         setFromCP(pathElement.getFromCP());
51         setToCP(pathElement.getToCP());
52         setFromCPOriginId(pathElement.getFromCPOriginId());
53         setToCPOriginId(pathElement.getToCPOriginId());
54     }
55
56     public String getFromNode() {
57         return (String) getToscaPresentationValue(JsonPresentationFields.FROM_NODE);
58     }
59
60     public void setFromNode(String fromNode) {
61         setToscaPresentationValue(JsonPresentationFields.FROM_NODE, fromNode);
62     }
63
64     public String getToNode() {
65         return (String) getToscaPresentationValue(JsonPresentationFields.TO_NODE);
66     }
67
68     public void setToNode(String toNode) {
69         setToscaPresentationValue(JsonPresentationFields.TO_NODE, toNode);
70     }
71
72     public String getFromCP() {
73         return (String) getToscaPresentationValue(JsonPresentationFields.PATH_FROM_CP);
74     }
75
76     public void setFromCP(String fromCP) {
77         setToscaPresentationValue(JsonPresentationFields.PATH_FROM_CP, fromCP);
78     }
79
80     public String getToCP() {
81         return (String) getToscaPresentationValue(JsonPresentationFields.PATH_TO_CP);
82     }
83
84     public void setToCP(String toCP) {
85         setToscaPresentationValue(JsonPresentationFields.PATH_TO_CP, toCP);
86     }
87
88     public String getToCPOriginId() {
89         return (String) getToscaPresentationValue(JsonPresentationFields.PATH_TO_CP_ORIGIN);
90     }
91
92     public void setToCPOriginId(String toCPOriginId) {
93         setToscaPresentationValue(JsonPresentationFields.PATH_TO_CP_ORIGIN, toCPOriginId);
94     }
95
96     public String getFromCPOriginId() {
97         return (String) getToscaPresentationValue(JsonPresentationFields.PATH_FROM_CP_ORIGIN);
98     }
99
100     public void setFromCPOriginId(String fromCPOriginId) {
101         setToscaPresentationValue(JsonPresentationFields.PATH_FROM_CP_ORIGIN, fromCPOriginId);
102     }
103
104     @Override
105     public boolean equals(Object o) {
106         if (this == o) return true;
107         if (o == null || getClass() != o.getClass()) return false;
108         ForwardingPathElementDataDefinition that = (ForwardingPathElementDataDefinition) o;
109         return Objects.equals(getFromNode(), that.getFromNode()) && Objects.equals(getToNode(), that.getToNode())
110                 && Objects.equals(getFromCPOriginId(), that.getFromCPOriginId())  && Objects.equals(getToCPOriginId(), that.getToCPOriginId());
111     }
112
113     @Override
114     public int hashCode() {
115         return Objects.hash(getFromNode(), getToNode(), getFromCP(),getToCP(), getFromCPOriginId(), getToCPOriginId());
116     }
117
118     @Override
119     public String toString() {
120         return MoreObjects.toStringHelper(this)
121                 .add("fromNode", getFromNode()).add("toNode", getToNode())
122                 .add("fromCPOriginId", getFromCPOriginId()).add("toCPOriginId", getToCPOriginId())
123                 .add("fromCPName", getFromCP()).add("toCPName", getToCP()).toString();
124     }
125 }