[POLICY-22] Reorganizing drools-apps
[policy/drools-applications.git] / controlloop / common / model-impl / sdc / src / main / java / org / onap / policy / sdc / Service.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 Service implements Serializable {
27
28         /**
29          * 
30          */
31         private static final long serialVersionUID = -1249276698549996806L;
32         
33         public UUID             serviceUUID;
34         public UUID             serviceInvariantUUID;
35         public String   serviceName;
36         public String   serviceVersion;
37         
38         public Service() {
39                 
40         }
41         
42         public Service(UUID uuid) {
43                 this.serviceUUID = uuid;
44         }
45         
46         public Service(String name) {
47                 this.serviceName = name;
48         }
49         
50         public Service(UUID uuid, UUID invariantUUID, String name, String version) {
51                 this.serviceUUID = uuid;
52                 this.serviceInvariantUUID = invariantUUID;
53                 this.serviceName = name;
54                 this.serviceVersion = version;
55         }
56         
57         public Service(Service service) {
58                 this.serviceUUID = service.serviceUUID;
59                 this.serviceInvariantUUID = service.serviceInvariantUUID;
60                 this.serviceName = service.serviceName;
61                 this.serviceVersion = service.serviceVersion;
62         }
63         
64         @Override
65         public String toString() {
66                 return "Service [serviceUUID=" + serviceUUID + ", serviceInvariantUUID=" + serviceInvariantUUID
67                                 + ", serviceName=" + serviceName + ", serviceVersion=" + serviceVersion + "]";
68         }
69         @Override
70         public int hashCode() {
71                 final int prime = 31;
72                 int result = 1;
73                 result = prime * result + ((serviceInvariantUUID == null) ? 0 : serviceInvariantUUID.hashCode());
74                 result = prime * result + ((serviceName == null) ? 0 : serviceName.hashCode());
75                 result = prime * result + ((serviceUUID == null) ? 0 : serviceUUID.hashCode());
76                 result = prime * result + ((serviceVersion == null) ? 0 : serviceVersion.hashCode());
77                 return result;
78         }
79         @Override
80         public boolean equals(Object obj) {
81                 if (this == obj)
82                         return true;
83                 if (obj == null)
84                         return false;
85                 if (getClass() != obj.getClass())
86                         return false;
87                 Service other = (Service) obj;
88                 if (serviceInvariantUUID == null) {
89                         if (other.serviceInvariantUUID != null)
90                                 return false;
91                 } else if (!serviceInvariantUUID.equals(other.serviceInvariantUUID))
92                         return false;
93                 if (serviceName == null) {
94                         if (other.serviceName != null)
95                                 return false;
96                 } else if (!serviceName.equals(other.serviceName))
97                         return false;
98                 if (serviceUUID == null) {
99                         if (other.serviceUUID != null)
100                                 return false;
101                 } else if (!serviceUUID.equals(other.serviceUUID))
102                         return false;
103                 if (serviceVersion == null) {
104                         if (other.serviceVersion != null)
105                                 return false;
106                 } else if (!serviceVersion.equals(other.serviceVersion))
107                         return false;
108                 return true;
109         }
110
111 }