Commit includes ControlLoopPolicy API and bugfixes
[policy/engine.git] / ECOMP-ASDC / src / main / java / org / openecomp / policy / asdc / ResourceInstance.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP Policy Engine
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.openecomp.policy.asdc;
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         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         public String getResourceInstanceName() {
53                 return resourceInstanceName;
54         }
55
56         public void setResourceInstanceName(String resourceInstanceName) {
57                 this.resourceInstanceName = resourceInstanceName;
58         }
59
60         public String getResourceName() {
61                 return resourceName;
62         }
63
64         public void setResourceName(String resourceName) {
65                 this.resourceName = resourceName;
66         }
67
68         public UUID getResourceInvariantUUID() {
69                 return resourceInvariantUUID;
70         }
71
72         public void setResourceInvariantUUID(UUID resourceInvariantUUID) {
73                 this.resourceInvariantUUID = resourceInvariantUUID;
74         }
75
76         public String getResourceVersion() {
77                 return resourceVersion;
78         }
79
80         public void setResourceVersion(String resourceVersion) {
81                 this.resourceVersion = resourceVersion;
82         }
83
84         public ResourceType getResourceType() {
85                 return resourceType;
86         }
87
88         public void setResourceType(ResourceType resourceType) {
89                 this.resourceType = resourceType;
90         }
91
92         public UUID getResourceUUID() {
93                 return resourceUUID;
94         }
95
96         public void setResourceUUID(UUID resourceUUID) {
97                 this.resourceUUID = resourceUUID;
98         }
99
100         @Override
101         public String toString() {
102                 return "ResourceInstance [resourceInstanceName=" + resourceInstanceName + ", resourceName=" + resourceName
103                                 + ", resourceInvariantUUID=" + resourceInvariantUUID + ", resourceVersion=" + resourceVersion
104                                 + ", resourceType=" + resourceType + ", resourceUUID=" + resourceUUID + "]";
105         }
106         @Override
107         public int hashCode() {
108                 final int prime = 31;
109                 int result = 1;
110                 result = prime * result + ((resourceInstanceName == null) ? 0 : resourceInstanceName.hashCode());
111                 result = prime * result + ((resourceInvariantUUID == null) ? 0 : resourceInvariantUUID.hashCode());
112                 result = prime * result + ((resourceName == null) ? 0 : resourceName.hashCode());
113                 result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode());
114                 result = prime * result + ((resourceUUID == null) ? 0 : resourceUUID.hashCode());
115                 result = prime * result + ((resourceVersion == null) ? 0 : resourceVersion.hashCode());
116                 return result;
117         }
118         @Override
119         public boolean equals(Object obj) {
120                 if (this == obj)
121                         return true;
122                 if (obj == null)
123                         return false;
124                 if (getClass() != obj.getClass())
125                         return false;
126                 ResourceInstance other = (ResourceInstance) obj;
127                 if (resourceInstanceName == null) {
128                         if (other.resourceInstanceName != null)
129                                 return false;
130                 } else if (!resourceInstanceName.equals(other.resourceInstanceName))
131                         return false;
132                 if (resourceInvariantUUID == null) {
133                         if (other.resourceInvariantUUID != null)
134                                 return false;
135                 } else if (!resourceInvariantUUID.equals(other.resourceInvariantUUID))
136                         return false;
137                 if (resourceName == null) {
138                         if (other.resourceName != null)
139                                 return false;
140                 } else if (!resourceName.equals(other.resourceName))
141                         return false;
142                 if (resourceType != other.resourceType)
143                         return false;
144                 if (resourceUUID == null) {
145                         if (other.resourceUUID != null)
146                                 return false;
147                 } else if (!resourceUUID.equals(other.resourceUUID))
148                         return false;
149                 if (resourceVersion == null) {
150                         if (other.resourceVersion != null)
151                                 return false;
152                 } else if (!resourceVersion.equals(other.resourceVersion))
153                         return false;
154                 return true;
155         }
156         
157 }