2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Nordix Foundation.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.sdc;
24 import java.io.Serializable;
25 import java.util.UUID;
27 public class Resource implements Serializable {
29 private static final long serialVersionUID = -913729158733348027L;
31 private UUID resourceUuid;
32 private UUID resourceInvariantUuid;
33 private String resourceName;
34 private String resourceVersion;
35 private ResourceType resourceType;
44 * @param resource copy object
46 public Resource(Resource resource) {
47 this.resourceUuid = resource.resourceUuid;
48 this.resourceInvariantUuid = resource.resourceInvariantUuid;
49 this.resourceName = resource.resourceName;
50 this.resourceVersion = resource.resourceVersion;
51 this.resourceType = resource.resourceType;
54 public Resource(UUID uuid) {
55 this.resourceUuid = uuid;
58 public Resource(String name, ResourceType type) {
59 this.resourceName = name;
60 this.resourceType = type;
67 * @param invariantUuid invariant uuid
69 * @param version version
72 public Resource(UUID uuid, UUID invariantUuid, String name, String version, ResourceType type) {
73 this.resourceUuid = uuid;
74 this.resourceInvariantUuid = invariantUuid;
75 this.resourceName = name;
76 this.resourceVersion = version;
77 this.resourceType = type;
80 public UUID getResourceUuid() {
84 public void setResourceUuid(UUID resourceUuid) {
85 this.resourceUuid = resourceUuid;
88 public UUID getResourceInvariantUuid() {
89 return resourceInvariantUuid;
92 public void setResourceInvariantUuid(UUID resourceInvariantUuid) {
93 this.resourceInvariantUuid = resourceInvariantUuid;
96 public String getResourceName() {
100 public void setResourceName(String resourceName) {
101 this.resourceName = resourceName;
104 public String getResourceVersion() {
105 return resourceVersion;
108 public void setResourceVersion(String resourceVersion) {
109 this.resourceVersion = resourceVersion;
112 public ResourceType getResourceType() {
116 public void setResourceType(ResourceType resourceType) {
117 this.resourceType = resourceType;
121 public String toString() {
122 return "Resource [resourceUuid=" + resourceUuid + ", resourceInvariantUuid=" + resourceInvariantUuid
123 + ", resourceName=" + resourceName + ", resourceVersion=" + resourceVersion + ", resourceType="
124 + resourceType + "]";
128 public int hashCode() {
129 final int prime = 31;
131 result = prime * result + ((resourceInvariantUuid == null) ? 0 : resourceInvariantUuid.hashCode());
132 result = prime * result + ((resourceName == null) ? 0 : resourceName.hashCode());
133 result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode());
134 result = prime * result + ((resourceUuid == null) ? 0 : resourceUuid.hashCode());
135 result = prime * result + ((resourceVersion == null) ? 0 : resourceVersion.hashCode());
140 public boolean equals(Object obj) {
147 if (getClass() != obj.getClass()) {
150 Resource other = (Resource) obj;
151 if (resourceInvariantUuid == null) {
152 if (other.resourceInvariantUuid != null) {
155 } else if (!resourceInvariantUuid.equals(other.resourceInvariantUuid)) {
158 if (resourceName == null) {
159 if (other.resourceName != null) {
162 } else if (!resourceName.equals(other.resourceName)) {
165 if (resourceType == null) {
166 if (other.resourceType != null) {
169 } else if (!resourceType.equals(other.resourceType)) {
172 if (resourceUuid == null) {
173 if (other.resourceUuid != null) {
176 } else if (!resourceUuid.equals(other.resourceUuid)) {
179 if (resourceVersion == null) {
180 if (other.resourceVersion != null) {
183 } else if (!resourceVersion.equals(other.resourceVersion)) {