Fix vFW Distrobution
[so.git] / asdc-controller / src / main / java / org / onap / so / asdc / client / test / emulators / ResourceInfoImpl.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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.onap.so.asdc.client.test.emulators;
22
23 import java.util.ArrayList;
24 import java.util.List;
25 import org.apache.commons.lang3.builder.EqualsBuilder;
26 import org.apache.commons.lang3.builder.HashCodeBuilder;
27 import org.onap.sdc.api.notification.IArtifactInfo;
28 import org.onap.sdc.api.notification.IResourceInstance;
29 import com.fasterxml.jackson.annotation.JsonIgnore;
30 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
31
32 @JsonIgnoreProperties(ignoreUnknown = true)
33 public class ResourceInfoImpl implements IResourceInstance {
34     public ResourceInfoImpl() {}
35
36     private String resourceInstanceName;
37     private String resourceCustomizationUUID;
38     private String resourceName;
39     private String resourceVersion;
40     private String resourceType;
41     private String resourceUUID;
42     private String resourceInvariantUUID;
43     private String category;
44     private String subcategory;
45     private List<ArtifactInfoImpl> artifacts;
46
47     private ResourceInfoImpl(IResourceInstance resourceInstance) {
48         resourceInstanceName = resourceInstance.getResourceInstanceName();
49         resourceCustomizationUUID = resourceInstance.getResourceCustomizationUUID();
50         resourceName = resourceInstance.getResourceName();
51         resourceVersion = resourceInstance.getResourceVersion();
52         resourceType = resourceInstance.getResourceType();
53         resourceUUID = resourceInstance.getResourceUUID();
54         resourceInvariantUUID = resourceInstance.getResourceInvariantUUID();
55         category = resourceInstance.getCategory();
56         subcategory = resourceInstance.getSubcategory();
57         artifacts = ArtifactInfoImpl.convertToArtifactInfoImpl(resourceInstance.getArtifacts());
58     }
59
60     public static List<ResourceInfoImpl> convertToJsonContainer(List<IResourceInstance> resources) {
61         List<ResourceInfoImpl> buildResources = new ArrayList<ResourceInfoImpl>();
62         if (resources != null) {
63             for (IResourceInstance resourceInstance : resources) {
64                 buildResources.add(new ResourceInfoImpl(resourceInstance));
65             }
66         }
67         return buildResources;
68     }
69
70     @Override
71     public String getResourceInstanceName() {
72         return resourceInstanceName;
73     }
74
75     public void setResourceInstanceName(String resourceInstanceName) {
76         this.resourceInstanceName = resourceInstanceName;
77     }
78
79     @Override
80     public String getResourceName() {
81         return resourceName;
82     }
83
84     public void setResourceName(String resourceName) {
85         this.resourceName = resourceName;
86     }
87
88     @Override
89     public String getResourceVersion() {
90         return resourceVersion;
91     }
92
93     public void setResourceVersion(String resourceVersion) {
94         this.resourceVersion = resourceVersion;
95     }
96
97     @Override
98     public String getResourceType() {
99         return resourceType;
100     }
101
102     public void setResoucreType(String resourceType) {
103         this.resourceType = resourceType;
104     }
105
106     @Override
107     public String getResourceUUID() {
108         return resourceUUID;
109     }
110
111     public void setResourceUUID(String resourceUUID) {
112         this.resourceUUID = resourceUUID;
113     }
114
115     @Override
116     public List<IArtifactInfo> getArtifacts() {
117         List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
118         if (artifacts != null) {
119             temp.addAll(artifacts);
120         }
121         return temp;
122     }
123
124     public void setArtifacts(List<ArtifactInfoImpl> artifacts) {
125         this.artifacts = artifacts;
126     }
127
128     @JsonIgnore
129     public List<ArtifactInfoImpl> getArtifactsImpl() {
130         return artifacts;
131     }
132
133     @Override
134     public String getResourceInvariantUUID() {
135         return resourceInvariantUUID;
136     }
137
138     public void setResourceInvariantUUID(String resourceInvariantUUID) {
139         this.resourceInvariantUUID = resourceInvariantUUID;
140     }
141
142     public String getResourceCustomizationUUID() {
143         return resourceCustomizationUUID;
144     }
145
146     public void setResourceCustomizationUUID(String resourceCustomizationUUID) {
147         this.resourceCustomizationUUID = resourceCustomizationUUID;
148     }
149
150     public String getCategory() {
151         return category;
152     }
153
154     public void setCategory(String category) {
155         this.category = category;
156     }
157
158     public String getSubcategory() {
159         return subcategory;
160     }
161
162     public void setSubcategory(String subcategory) {
163         this.subcategory = subcategory;
164     }
165
166     @Override
167     public boolean equals(final Object other) {
168         if (!(other instanceof ResourceInfoImpl)) {
169             return false;
170         }
171         ResourceInfoImpl castOther = (ResourceInfoImpl) other;
172         return new EqualsBuilder().append(resourceUUID, castOther.resourceUUID)
173                 .append(resourceVersion, castOther.resourceVersion).isEquals();
174     }
175
176     @Override
177     public int hashCode() {
178         return new HashCodeBuilder().append(resourceInstanceName).append(resourceCustomizationUUID).append(resourceName)
179                 .append(resourceVersion).append(resourceType).append(resourceUUID).append(resourceInvariantUUID)
180                 .append(category).append(subcategory).append(artifacts).toHashCode();
181     }
182 }