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;
31 public class Resource implements Serializable {
33 private static final long serialVersionUID = -913729158733348027L;
35 private UUID resourceUuid;
36 private UUID resourceInvariantUuid;
37 private String resourceName;
38 private String resourceVersion;
39 private String resourceType;
48 * @param resource copy object
50 public Resource(Resource resource) {
51 this.resourceUuid = resource.resourceUuid;
52 this.resourceInvariantUuid = resource.resourceInvariantUuid;
53 this.resourceName = resource.resourceName;
54 this.resourceVersion = resource.resourceVersion;
55 this.resourceType = resource.resourceType;
58 public Resource(UUID uuid) {
59 this.resourceUuid = uuid;
62 public Resource(String name, String type) {
63 this.resourceName = name;
64 this.resourceType = type;
71 * @param invariantUuid invariant uuid
73 * @param version version
76 public Resource(UUID uuid, UUID invariantUuid, String name, String version, String type) {
77 this.resourceUuid = uuid;
78 this.resourceInvariantUuid = invariantUuid;
79 this.resourceName = name;
80 this.resourceVersion = version;
81 this.resourceType = type;
85 public String toString() {
86 return "Resource [resourceUuid=" + resourceUuid + ", resourceInvariantUuid=" + resourceInvariantUuid
87 + ", resourceName=" + resourceName + ", resourceVersion=" + resourceVersion + ", resourceType="
92 public int hashCode() {
95 result = prime * result + ((resourceInvariantUuid == null) ? 0 : resourceInvariantUuid.hashCode());
96 result = prime * result + ((resourceName == null) ? 0 : resourceName.hashCode());
97 result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode());
98 result = prime * result + ((resourceUuid == null) ? 0 : resourceUuid.hashCode());
99 result = prime * result + ((resourceVersion == null) ? 0 : resourceVersion.hashCode());
104 public boolean equals(Object obj) {
111 if (getClass() != obj.getClass()) {
114 Resource other = (Resource) obj;
115 if (resourceInvariantUuid == null) {
116 if (other.resourceInvariantUuid != null) {
119 } else if (!resourceInvariantUuid.equals(other.resourceInvariantUuid)) {
122 if (resourceName == null) {
123 if (other.resourceName != null) {
126 } else if (!resourceName.equals(other.resourceName)) {
129 if (resourceType == null) {
130 if (other.resourceType != null) {
133 } else if (!resourceType.equals(other.resourceType)) {
136 if (resourceUuid == null) {
137 if (other.resourceUuid != null) {
140 } else if (!resourceUuid.equals(other.resourceUuid)) {
143 if (resourceVersion == null) {
144 if (other.resourceVersion != null) {
147 } else if (!resourceVersion.equals(other.resourceVersion)) {