[SDC] rebase 1710 code
[sdc.git] / catalog-model / src / main / java / org / openecomp / sdc / be / model / RequirementAndRelationshipPair.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 java.io.Serializable;
24
25 import org.openecomp.sdc.be.datatypes.elements.RelationshipInstDataDefinition;
26
27 public class RequirementAndRelationshipPair implements Serializable {
28
29         /**
30          * 
31          */
32         private static final long serialVersionUID = -5763126570618602135L;
33
34         private String requirement;
35         private String capabilityOwnerId;
36         private String requirementOwnerId;
37         private String id;
38
39         private RelationshipImpl relationship;
40
41         private String capability;
42
43         private String capabilityUid;
44         private String requirementUid;
45
46         public RequirementAndRelationshipPair() {
47                 super();
48         }
49
50         public RequirementAndRelationshipPair(String requirement, RelationshipImpl relationship) {
51                 super();
52                 this.requirement = requirement;
53                 this.relationship = relationship;
54         }
55
56         public RequirementAndRelationshipPair(String requirement, RelationshipImpl relationship, String capability) {
57                 super();
58                 this.requirement = requirement;
59                 this.relationship = relationship;
60                 this.capability = capability;
61         }
62
63         public String getRequirement() {
64                 return requirement;
65         }
66
67         public void setRequirement(String requirement) {
68                 this.requirement = requirement;
69         }
70
71         public String getCapabilityOwnerId() {
72                 return capabilityOwnerId;
73         }
74
75         public void setCapabilityOwnerId(String capabilityOwnerId) {
76                 this.capabilityOwnerId = capabilityOwnerId;
77         }
78
79         public String getRequirementOwnerId() {
80                 return requirementOwnerId;
81         }
82
83         public void setRequirementOwnerId(String requirementOwnerId) {
84                 this.requirementOwnerId = requirementOwnerId;
85         }
86
87         public RelationshipImpl getRelationship() {
88                 return relationship;
89         }
90
91         public void setRelationships(RelationshipImpl relationship) {
92                 this.relationship = relationship;
93         }
94
95         public String getCapability() {
96                 return capability;
97         }
98
99         public void setCapability(String capability) {
100                 this.capability = capability;
101         }
102
103         public String getCapabilityUid() {
104                 return capabilityUid;
105         }
106
107         public void setCapabilityUid(String capabilityUid) {
108                 this.capabilityUid = capabilityUid;
109         }
110
111         public String getRequirementUid() {
112                 return requirementUid;
113         }
114
115         public void setRequirementUid(String requirementUid) {
116                 this.requirementUid = requirementUid;
117         }
118
119         public String getId() {
120                 return id;
121         }
122
123         public void setId(String id) {
124                 this.id = id;
125         }
126
127         @Override
128         public String toString() {
129                 return "RequirementAndRelationshipPair [requirement=" + requirement + ", relationship=" + relationship
130                                 + ", capability=" + capability + "]";
131         }
132
133         public boolean equalsTo( RelationshipInstDataDefinition savedRelation){
134                 if ( savedRelation == null ){
135                         return false;
136                 }
137                 if ( !savedRelation.getType().equals(this.getRelationship().getType()) ){
138                         return false;
139                 }       
140                 if ( !savedRelation.getCapabilityOwnerId().equals(this.getCapabilityOwnerId()) ){
141                         return false;
142                 }
143                 if ( !savedRelation.getRequirementOwnerId().equals(this.getRequirementOwnerId()) ){
144                         return false;
145                 }
146                 if ( !savedRelation.getRequirementId().equals(this.getRequirementUid()) ){
147                         return false;
148                 }
149                 if ( !savedRelation.getCapabilityId().equals(this.getCapabilityUid()) ){
150                         return false;
151                 }
152                 if ( !savedRelation.getRequirement().equals(this.getRequirement()) ){
153                         return false;
154                 }
155                 return true;
156         }
157 }