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;
26 import org.apache.commons.lang3.builder.EqualsBuilder;
27 import org.apache.commons.lang3.builder.HashCodeBuilder;
28 import org.onap.sdc.api.notification.IArtifactInfo;
29 import org.onap.sdc.api.notification.IResourceInstance;
31 import com.fasterxml.jackson.annotation.JsonIgnore;
33 public class ResourceInfoImpl implements IResourceInstance{
35 private String resourceInstanceName;
36 private String resourceCustomizationUUID;
37 private String resourceName;
38 private String resourceVersion;
39 private String resourceType;
40 private String resourceUUID;
41 private String resourceInvariantUUID;
42 private String category;
43 private String subcategory;
44 private List<ArtifactInfoImpl> artifacts;
46 private ResourceInfoImpl(IResourceInstance resourceInstance){
47 resourceInstanceName = resourceInstance.getResourceInstanceName();
48 resourceCustomizationUUID = resourceInstance.getResourceCustomizationUUID();
49 resourceName = resourceInstance.getResourceName();
50 resourceVersion = resourceInstance.getResourceVersion();
51 resourceType = resourceInstance.getResourceType();
52 resourceUUID = resourceInstance.getResourceUUID();
53 resourceInvariantUUID = resourceInstance.getResourceInvariantUUID();
54 category = resourceInstance.getCategory();
55 subcategory = resourceInstance.getSubcategory();
56 artifacts = ArtifactInfoImpl.convertToArtifactInfoImpl(resourceInstance.getArtifacts());
59 public static List<ResourceInfoImpl> convertToJsonContainer(List<IResourceInstance> resources){
60 List<ResourceInfoImpl> buildResources = new ArrayList<ResourceInfoImpl>();
61 if( resources != null ){
62 for( IResourceInstance resourceInstance : resources ){
63 buildResources.add(new ResourceInfoImpl(resourceInstance));
66 return buildResources;
70 public String getResourceInstanceName() {
71 return resourceInstanceName;
74 public void setResourceInstanceName(String resourceInstanceName) {
75 this.resourceInstanceName = resourceInstanceName;
79 public String getResourceName() {
83 public void setResourceName(String resourceName) {
84 this.resourceName = resourceName;
88 public String getResourceVersion() {
89 return resourceVersion;
92 public void setResourceVersion(String resourceVersion) {
93 this.resourceVersion = resourceVersion;
97 public String getResourceType() {
101 public void setResoucreType(String resourceType) {
102 this.resourceType = resourceType;
106 public String getResourceUUID() {
110 public void setResourceUUID(String resourceUUID) {
111 this.resourceUUID = resourceUUID;
115 public List<IArtifactInfo> getArtifacts() {
116 List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
117 if( artifacts != null ){
118 temp.addAll(artifacts);
123 public void setArtifacts(List<ArtifactInfoImpl> artifacts) {
124 this.artifacts = artifacts;
128 public List<ArtifactInfoImpl> getArtifactsImpl() {
133 public String getResourceInvariantUUID() {
134 return resourceInvariantUUID;
137 public void setResourceInvariantUUID(String resourceInvariantUUID) {
138 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();