2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.asdc.client.test.emulators;
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;
32 @JsonIgnoreProperties(ignoreUnknown = true)
33 public class ResourceInfoImpl implements IResourceInstance {
34 public ResourceInfoImpl() {}
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;
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());
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));
67 return buildResources;
71 public String getResourceInstanceName() {
72 return resourceInstanceName;
75 public void setResourceInstanceName(String resourceInstanceName) {
76 this.resourceInstanceName = resourceInstanceName;
80 public String getResourceName() {
84 public void setResourceName(String resourceName) {
85 this.resourceName = resourceName;
89 public String getResourceVersion() {
90 return resourceVersion;
93 public void setResourceVersion(String resourceVersion) {
94 this.resourceVersion = resourceVersion;
98 public String getResourceType() {
102 public void setResoucreType(String resourceType) {
103 this.resourceType = resourceType;
107 public String getResourceUUID() {
111 public void setResourceUUID(String resourceUUID) {
112 this.resourceUUID = resourceUUID;
116 public List<IArtifactInfo> getArtifacts() {
117 List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
118 if (artifacts != null) {
119 temp.addAll(artifacts);
124 public void setArtifacts(List<ArtifactInfoImpl> artifacts) {
125 this.artifacts = artifacts;
129 public List<ArtifactInfoImpl> getArtifactsImpl() {
134 public String getResourceInvariantUUID() {
135 return resourceInvariantUUID;
138 public void setResourceInvariantUUID(String resourceInvariantUUID) {
139 this.resourceInvariantUUID = resourceInvariantUUID;
142 public String getResourceCustomizationUUID() {
143 return resourceCustomizationUUID;
146 public void setResourceCustomizationUUID(String resourceCustomizationUUID) {
147 this.resourceCustomizationUUID = resourceCustomizationUUID;
150 public String getCategory() {
154 public void setCategory(String category) {
155 this.category = category;
158 public String getSubcategory() {
162 public void setSubcategory(String subcategory) {
163 this.subcategory = subcategory;
167 public boolean equals(final Object other) {
168 if (!(other instanceof ResourceInfoImpl)) {
171 ResourceInfoImpl castOther = (ResourceInfoImpl) other;
172 return new EqualsBuilder().append(resourceUUID, castOther.resourceUUID)
173 .append(resourceVersion, castOther.resourceVersion).isEquals();
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();