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