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