9c1db8a55fe9a8f0487f37f596884a2ac4b4cfe3
[policy/models.git] / models-interactions / model-impl / sdc / src / main / java / org / onap / policy / sdc / ResourceInstance.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * sdc
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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  */
21
22 package org.onap.policy.sdc;
23
24 import java.io.Serializable;
25 import java.util.UUID;
26
27 public class ResourceInstance implements Serializable {
28
29     private static final long serialVersionUID = -5506162340393802424L;
30
31     private String resourceInstanceName;
32     private String resourceName;
33     private UUID resourceInvariantUuid;
34     private String resourceVersion;
35     private ResourceType resourceType;
36     private UUID resourceUuid;
37
38     public ResourceInstance() {
39         //Empty Constructor
40     }
41
42     /**
43      * Constructor.
44      *
45      * @param instance copy object
46      */
47     public ResourceInstance(ResourceInstance instance) {
48         if (instance == null) {
49             return;
50         }
51         this.resourceInstanceName = instance.resourceInstanceName;
52         this.resourceName = instance.resourceName;
53         this.resourceInvariantUuid = instance.resourceInvariantUuid;
54         this.resourceVersion = instance.resourceVersion;
55         this.resourceType = instance.resourceType;
56         this.resourceUuid = instance.resourceUuid;
57     }
58
59     public String getResourceInstanceName() {
60         return resourceInstanceName;
61     }
62
63     public void setResourceInstanceName(String resourceInstanceName) {
64         this.resourceInstanceName = resourceInstanceName;
65     }
66
67     public String getResourceName() {
68         return resourceName;
69     }
70
71     public void setResourceName(String resourceName) {
72         this.resourceName = resourceName;
73     }
74
75     public UUID getResourceInvariantUUID() {
76         return resourceInvariantUuid;
77     }
78
79     public void setResourceInvariantUUID(UUID resourceInvariantUuid) {
80         this.resourceInvariantUuid = resourceInvariantUuid;
81     }
82
83     public String getResourceVersion() {
84         return resourceVersion;
85     }
86
87     public void setResourceVersion(String resourceVersion) {
88         this.resourceVersion = resourceVersion;
89     }
90
91     public ResourceType getResourceType() {
92         return resourceType;
93     }
94
95     public void setResourceType(ResourceType resourceType) {
96         this.resourceType = resourceType;
97     }
98
99     public UUID getResourceUuid() {
100         return resourceUuid;
101     }
102
103     public void setResourceUuid(UUID resourceUuid) {
104         this.resourceUuid = resourceUuid;
105     }
106
107     @Override
108     public String toString() {
109         return "ResourceInstance [resourceInstanceName=" + resourceInstanceName + ", resourceName=" + resourceName
110             + ", resourceInvariantUuid=" + resourceInvariantUuid + ", resourceVersion=" + resourceVersion
111             + ", resourceType=" + resourceType + ", resourceUuid=" + resourceUuid + "]";
112     }
113
114     @Override
115     public int hashCode() {
116         final int prime = 31;
117         int result = 1;
118         result = prime * result + ((resourceInstanceName == null) ? 0 : resourceInstanceName.hashCode());
119         result = prime * result + ((resourceInvariantUuid == null) ? 0 : resourceInvariantUuid.hashCode());
120         result = prime * result + ((resourceName == null) ? 0 : resourceName.hashCode());
121         result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode());
122         result = prime * result + ((resourceUuid == null) ? 0 : resourceUuid.hashCode());
123         result = prime * result + ((resourceVersion == null) ? 0 : resourceVersion.hashCode());
124         return result;
125     }
126
127     @Override
128     public boolean equals(Object obj) {
129         if (this == obj) {
130             return true;
131         }
132         if (obj == null) {
133             return false;
134         }
135         if (getClass() != obj.getClass()) {
136             return false;
137         }
138         ResourceInstance other = (ResourceInstance) obj;
139         if (resourceInstanceName == null) {
140             if (other.resourceInstanceName != null) {
141                 return false;
142             }
143         } else if (!resourceInstanceName.equals(other.resourceInstanceName)) {
144             return false;
145         }
146         if (resourceInvariantUuid == null) {
147             if (other.resourceInvariantUuid != null) {
148                 return false;
149             }
150         } else if (!resourceInvariantUuid.equals(other.resourceInvariantUuid)) {
151             return false;
152         }
153         if (resourceName == null) {
154             if (other.resourceName != null) {
155                 return false;
156             }
157         } else if (!resourceName.equals(other.resourceName)) {
158             return false;
159         }
160         if (resourceType != other.resourceType) {
161             return false;
162         }
163         if (resourceUuid == null) {
164             if (other.resourceUuid != null) {
165                 return false;
166             }
167         } else if (!resourceUuid.equals(other.resourceUuid)) {
168             return false;
169         }
170         if (resourceVersion == null) {
171             if (other.resourceVersion != null) {
172                 return false;
173             }
174         } else if (!resourceVersion.equals(other.resourceVersion)) {
175             return false;
176         }
177         return true;
178     }
179
180 }