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