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;
31 public class ResourceInfoImpl implements IResourceInstance {
32 public ResourceInfoImpl() {}
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;
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());
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));
65 return buildResources;
69 public String getResourceInstanceName() {
70 return resourceInstanceName;
73 public void setResourceInstanceName(String resourceInstanceName) {
74 this.resourceInstanceName = resourceInstanceName;
78 public String getResourceName() {
82 public void setResourceName(String resourceName) {
83 this.resourceName = resourceName;
87 public String getResourceVersion() {
88 return resourceVersion;
91 public void setResourceVersion(String resourceVersion) {
92 this.resourceVersion = resourceVersion;
96 public String getResourceType() {
100 public void setResoucreType(String resourceType) {
101 this.resourceType = resourceType;
105 public String getResourceUUID() {
109 public void setResourceUUID(String resourceUUID) {
110 this.resourceUUID = resourceUUID;
114 public List<IArtifactInfo> getArtifacts() {
115 List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
116 if (artifacts != null) {
117 temp.addAll(artifacts);
122 public void setArtifacts(List<ArtifactInfoImpl> artifacts) {
123 this.artifacts = artifacts;
127 public List<ArtifactInfoImpl> getArtifactsImpl() {
132 public String getResourceInvariantUUID() {
133 return resourceInvariantUUID;
136 public void setResourceInvariantUUID(String resourceInvariantUUID) {
137 this.resourceInvariantUUID = resourceInvariantUUID;
140 public String getResourceCustomizationUUID() {
141 return resourceCustomizationUUID;
144 public void setResourceCustomizationUUID(String resourceCustomizationUUID) {
145 this.resourceCustomizationUUID = resourceCustomizationUUID;
148 public String getCategory() {
152 public void setCategory(String category) {
153 this.category = category;
156 public String getSubcategory() {
160 public void setSubcategory(String subcategory) {
161 this.subcategory = subcategory;
165 public boolean equals(final Object other) {
166 if (!(other instanceof ResourceInfoImpl)) {
169 ResourceInfoImpl castOther = (ResourceInfoImpl) other;
170 return new EqualsBuilder().append(resourceUUID, castOther.resourceUUID)
171 .append(resourceVersion, castOther.resourceVersion).isEquals();
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();