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