[POLICY-22] Reorganizing drools-apps
[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 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         public String resourceInstanceName;
30         public String resourceName;
31         public UUID     resourceInvariantUUID;
32         public String resourceVersion;
33         public ResourceType resourceType;
34         public UUID     resourceUUID;
35         
36         public ResourceInstance() {
37                 
38         }
39         
40         public ResourceInstance(ResourceInstance instance) {
41                 if (instance == null) { 
42                         return;
43                 }
44                 this.resourceInstanceName = instance.resourceInstanceName;
45                 this.resourceName = instance.resourceName;
46                 this.resourceInvariantUUID = instance.resourceInvariantUUID;
47                 this.resourceVersion = instance.resourceVersion;
48                 this.resourceType = instance.resourceType;
49                 this.resourceUUID = instance.resourceUUID;
50         }
51         
52         @Override
53         public String toString() {
54                 return "ResourceInstance [resourceInstanceName=" + resourceInstanceName + ", resourceName=" + resourceName
55                                 + ", resourceInvariantUUID=" + resourceInvariantUUID + ", resourceVersion=" + resourceVersion
56                                 + ", resourceType=" + resourceType + ", resourceUUID=" + resourceUUID + "]";
57         }
58         @Override
59         public int hashCode() {
60                 final int prime = 31;
61                 int result = 1;
62                 result = prime * result + ((resourceInstanceName == null) ? 0 : resourceInstanceName.hashCode());
63                 result = prime * result + ((resourceInvariantUUID == null) ? 0 : resourceInvariantUUID.hashCode());
64                 result = prime * result + ((resourceName == null) ? 0 : resourceName.hashCode());
65                 result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode());
66                 result = prime * result + ((resourceUUID == null) ? 0 : resourceUUID.hashCode());
67                 result = prime * result + ((resourceVersion == null) ? 0 : resourceVersion.hashCode());
68                 return result;
69         }
70         @Override
71         public boolean equals(Object obj) {
72                 if (this == obj)
73                         return true;
74                 if (obj == null)
75                         return false;
76                 if (getClass() != obj.getClass())
77                         return false;
78                 ResourceInstance other = (ResourceInstance) obj;
79                 if (resourceInstanceName == null) {
80                         if (other.resourceInstanceName != null)
81                                 return false;
82                 } else if (!resourceInstanceName.equals(other.resourceInstanceName))
83                         return false;
84                 if (resourceInvariantUUID == null) {
85                         if (other.resourceInvariantUUID != null)
86                                 return false;
87                 } else if (!resourceInvariantUUID.equals(other.resourceInvariantUUID))
88                         return false;
89                 if (resourceName == null) {
90                         if (other.resourceName != null)
91                                 return false;
92                 } else if (!resourceName.equals(other.resourceName))
93                         return false;
94                 if (resourceType != other.resourceType)
95                         return false;
96                 if (resourceUUID == null) {
97                         if (other.resourceUUID != null)
98                                 return false;
99                 } else if (!resourceUUID.equals(other.resourceUUID))
100                         return false;
101                 if (resourceVersion == null) {
102                         if (other.resourceVersion != null)
103                                 return false;
104                 } else if (!resourceVersion.equals(other.resourceVersion))
105                         return false;
106                 return true;
107         }
108         
109 }