05842e24c6d075bcf51f09b488adb7d64a89a940
[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 import lombok.Getter;
27 import lombok.Setter;
28
29 @Getter
30 @Setter
31 public class ResourceInstance implements Serializable {
32
33     private static final long serialVersionUID = -5506162340393802424L;
34
35     private String resourceInstanceName;
36     private String resourceName;
37     private UUID resourceInvariantUuid;
38     private String resourceVersion;
39     private String resourceType;
40     private UUID resourceUuid;
41
42     public ResourceInstance() {
43         //Empty Constructor
44     }
45
46     /**
47      * Constructor.
48      *
49      * @param instance copy object
50      */
51     public ResourceInstance(ResourceInstance instance) {
52         if (instance == null) {
53             return;
54         }
55         this.resourceInstanceName = instance.resourceInstanceName;
56         this.resourceName = instance.resourceName;
57         this.resourceInvariantUuid = instance.resourceInvariantUuid;
58         this.resourceVersion = instance.resourceVersion;
59         this.resourceType = instance.resourceType;
60         this.resourceUuid = instance.resourceUuid;
61     }
62
63     public UUID getResourceInvariantUUID() {
64         return resourceInvariantUuid;
65     }
66
67     public void setResourceInvariantUUID(UUID resourceInvariantUuid) {
68         this.resourceInvariantUuid = resourceInvariantUuid;
69     }
70
71     @Override
72     public String toString() {
73         return "ResourceInstance [resourceInstanceName=" + resourceInstanceName + ", resourceName=" + resourceName
74             + ", resourceInvariantUuid=" + resourceInvariantUuid + ", resourceVersion=" + resourceVersion
75             + ", resourceType=" + resourceType + ", resourceUuid=" + resourceUuid + "]";
76     }
77
78     @Override
79     public int hashCode() {
80         final int prime = 31;
81         int result = 1;
82         result = prime * result + ((resourceInstanceName == null) ? 0 : resourceInstanceName.hashCode());
83         result = prime * result + ((resourceInvariantUuid == null) ? 0 : resourceInvariantUuid.hashCode());
84         result = prime * result + ((resourceName == null) ? 0 : resourceName.hashCode());
85         result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode());
86         result = prime * result + ((resourceUuid == null) ? 0 : resourceUuid.hashCode());
87         result = prime * result + ((resourceVersion == null) ? 0 : resourceVersion.hashCode());
88         return result;
89     }
90
91     @Override
92     public boolean equals(Object obj) {
93         if (this == obj) {
94             return true;
95         }
96         if (obj == null) {
97             return false;
98         }
99         if (getClass() != obj.getClass()) {
100             return false;
101         }
102         ResourceInstance other = (ResourceInstance) obj;
103         if (resourceInstanceName == null) {
104             if (other.resourceInstanceName != null) {
105                 return false;
106             }
107         } else if (!resourceInstanceName.equals(other.resourceInstanceName)) {
108             return false;
109         }
110         if (resourceInvariantUuid == null) {
111             if (other.resourceInvariantUuid != null) {
112                 return false;
113             }
114         } else if (!resourceInvariantUuid.equals(other.resourceInvariantUuid)) {
115             return false;
116         }
117         if (resourceName == null) {
118             if (other.resourceName != null) {
119                 return false;
120             }
121         } else if (!resourceName.equals(other.resourceName)) {
122             return false;
123         }
124         if (resourceType != other.resourceType) {
125             return false;
126         }
127         if (resourceUuid == null) {
128             if (other.resourceUuid != null) {
129                 return false;
130             }
131         } else if (!resourceUuid.equals(other.resourceUuid)) {
132             return false;
133         }
134         if (resourceVersion == null) {
135             if (other.resourceVersion != null) {
136                 return false;
137             }
138         } else if (!resourceVersion.equals(other.resourceVersion)) {
139             return false;
140         }
141         return true;
142     }
143
144 }