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