Merge "Add debugging of REST call"
[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-2018 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     private static final long serialVersionUID = -1249276698549996806L;
29     
30     private UUID        serviceUUID;
31     private UUID        serviceInvariantUUID;
32     private String  serviceName;
33     private String  serviceVersion;
34     
35     public Service() {
36         //Empty Constructor
37     }
38     
39     public Service(UUID uuid) {
40         this.serviceUUID = uuid;
41     }
42     
43     public Service(String name) {
44         this.serviceName = name;
45     }
46     
47     /**
48      * Constructor.
49      * 
50      * @param uuid service id
51      * @param invariantUUID service invariant id
52      * @param name name
53      * @param version version
54      */
55     public Service(UUID uuid, UUID invariantUUID, String name, String version) {
56         this.serviceUUID = uuid;
57         this.serviceInvariantUUID = invariantUUID;
58         this.serviceName = name;
59         this.serviceVersion = version;
60     }
61     
62     /**
63      * Constructor.
64      * 
65      * @param service copy object
66      */
67     public Service(Service service) {
68         this.serviceUUID = service.serviceUUID;
69         this.serviceInvariantUUID = service.serviceInvariantUUID;
70         this.serviceName = service.serviceName;
71         this.serviceVersion = service.serviceVersion;
72     }
73     
74     public UUID getServiceUUID() {
75         return serviceUUID;
76     }
77
78     public void setServiceUUID(UUID serviceUUID) {
79         this.serviceUUID = serviceUUID;
80     }
81
82     public UUID getServiceInvariantUUID() {
83         return serviceInvariantUUID;
84     }
85
86     public void setServiceInvariantUUID(UUID serviceInvariantUUID) {
87         this.serviceInvariantUUID = serviceInvariantUUID;
88     }
89
90     public String getServiceName() {
91         return serviceName;
92     }
93
94     public void setServiceName(String serviceName) {
95         this.serviceName = serviceName;
96     }
97
98     public String getServiceVersion() {
99         return serviceVersion;
100     }
101
102     public void setServiceVersion(String serviceVersion) {
103         this.serviceVersion = serviceVersion;
104     }
105
106     @Override
107     public String toString() {
108         return "Service [serviceUUID=" + serviceUUID + ", serviceInvariantUUID=" + serviceInvariantUUID
109                 + ", serviceName=" + serviceName + ", serviceVersion=" + serviceVersion + "]";
110     }
111     
112     @Override
113     public int hashCode() {
114         final int prime = 31;
115         int result = 1;
116         result = prime * result + ((serviceInvariantUUID == null) ? 0 : serviceInvariantUUID.hashCode());
117         result = prime * result + ((serviceName == null) ? 0 : serviceName.hashCode());
118         result = prime * result + ((serviceUUID == null) ? 0 : serviceUUID.hashCode());
119         result = prime * result + ((serviceVersion == null) ? 0 : serviceVersion.hashCode());
120         return result;
121     }
122
123     @Override
124     public boolean equals(Object obj) {
125         if (this == obj) {
126             return true;
127         }
128         if (obj == null) {
129             return false;
130         }
131         if (getClass() != obj.getClass()) {
132             return false;
133         }
134         Service other = (Service) obj;
135         if (serviceInvariantUUID == null) {
136             if (other.serviceInvariantUUID != null) {
137                 return false;
138             }
139         } else if (!serviceInvariantUUID.equals(other.serviceInvariantUUID)) {
140             return false;
141         }
142         if (serviceName == null) {
143             if (other.serviceName != null) {
144                 return false;
145             }
146         } else if (!serviceName.equals(other.serviceName)) {
147             return false;
148         }
149         if (serviceUUID == null) {
150             if (other.serviceUUID != null) {
151                 return false;
152             }
153         } else if (!serviceUUID.equals(other.serviceUUID)) {
154             return false;
155         }
156         if (serviceVersion == null) {
157             if (other.serviceVersion != null) {
158                 return false;
159             }
160         } else if (!serviceVersion.equals(other.serviceVersion)) {
161             return false;
162         }
163         return true;
164     }
165
166 }