d12676340940d6df3b4d4a6c64a40051ce432145
[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.vendorsoftwareproduct.types.composition;
22
23 import java.util.ArrayList;
24 import java.util.Collection;
25
26 public class CompositionEntityValidationData {
27   private CompositionEntityType entityType;
28   private String entityId;
29   private String entityName;
30   private Collection<String> errors;
31   private Collection<CompositionEntityValidationData> subEntitiesValidationData;
32
33   public CompositionEntityValidationData(CompositionEntityType entityType, String entityId) {
34     this.entityType = entityType;
35     this.entityId = entityId;
36   }
37
38   public String getEntityName() {
39     return entityName;
40   }
41
42   public void setEntityName(String entityName) {
43     this.entityName = entityName;
44   }
45
46   public CompositionEntityType getEntityType() {
47     return entityType;
48   }
49
50   public void setEntityType(CompositionEntityType entityType) {
51     this.entityType = entityType;
52   }
53
54   public String getEntityId() {
55     return entityId;
56   }
57
58   public void setEntityId(String entityId) {
59     this.entityId = entityId;
60   }
61
62   public Collection<String> getErrors() {
63     return errors;
64   }
65
66   public void setErrors(Collection<String> errors) {
67     this.errors = errors;
68   }
69
70   public Collection<CompositionEntityValidationData> getSubEntitiesValidationData() {
71     return subEntitiesValidationData;
72   }
73
74   public void setSubEntitiesValidationData(Collection<CompositionEntityValidationData> toSet) {
75     this.subEntitiesValidationData = toSet;
76   }
77
78   /**
79    * Add sub entity validation data.
80    *
81    * @param subEntityValidationData the sub entity validation data
82    */
83   public void addSubEntityValidationData(CompositionEntityValidationData subEntityValidationData) {
84     if (subEntitiesValidationData == null) {
85       subEntitiesValidationData = new ArrayList<>();
86     }
87     subEntitiesValidationData.add(subEntityValidationData);
88   }
89
90   @Override
91   public boolean equals(Object o) {
92     if (this == o) {
93       return true;
94     }
95     if (o == null || getClass() != o.getClass()) {
96       return false;
97     }
98
99     CompositionEntityValidationData that = (CompositionEntityValidationData) o;
100
101     if (entityType != that.entityType) {
102       return false;
103     }
104     if (entityId != null ? !entityId.equals(that.entityId) : that.entityId != null) {
105       return false;
106     }
107     if (entityName != null ? !entityName.equals(that.entityName) : that.entityName != null) {
108       return false;
109     }
110     if (errors != null ? !errors.equals(that.errors) : that.errors != null) {
111       return false;
112     }
113     if (subEntitiesValidationData != null ? !subEntitiesValidationData
114         .equals(that.subEntitiesValidationData) : that.subEntitiesValidationData != null) {
115       return false;
116     }
117
118     return true;
119   }
120
121   @Override
122   public int hashCode() {
123     int result = entityType != null ? entityType.hashCode() : 0;
124     result = 31 * result + (entityId != null ? entityId.hashCode() : 0);
125     result = 31 * result + (entityName != null ? entityName.hashCode() : 0);
126     result = 31 * result + (errors != null ? errors.hashCode() : 0);
127     result =
128         31 * result +
129             (subEntitiesValidationData != null ? subEntitiesValidationData.hashCode() : 0);
130     return result;
131   }
132 }