2 * ============LICENSE_START=======================================================
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.policy.sdc;
24 import java.io.Serializable;
25 import java.util.UUID;
31 public class Service implements Serializable {
33 private static final long serialVersionUID = -1249276698549996806L;
35 private UUID serviceUUID;
36 private UUID serviceInvariantUUID;
37 private String serviceName;
38 private String serviceVersion;
44 public Service(UUID uuid) {
45 this.serviceUUID = uuid;
48 public Service(String name) {
49 this.serviceName = name;
55 * @param uuid service id
56 * @param invariantUUID service invariant id
58 * @param version version
60 public Service(UUID uuid, UUID invariantUUID, String name, String version) {
61 this.serviceUUID = uuid;
62 this.serviceInvariantUUID = invariantUUID;
63 this.serviceName = name;
64 this.serviceVersion = version;
70 * @param service copy object
72 public Service(Service service) {
73 this.serviceUUID = service.serviceUUID;
74 this.serviceInvariantUUID = service.serviceInvariantUUID;
75 this.serviceName = service.serviceName;
76 this.serviceVersion = service.serviceVersion;
80 public String toString() {
81 return "Service [serviceUUID=" + serviceUUID + ", serviceInvariantUUID=" + serviceInvariantUUID
82 + ", serviceName=" + serviceName + ", serviceVersion=" + serviceVersion + "]";
86 public int hashCode() {
89 result = prime * result + ((serviceInvariantUUID == null) ? 0 : serviceInvariantUUID.hashCode());
90 result = prime * result + ((serviceName == null) ? 0 : serviceName.hashCode());
91 result = prime * result + ((serviceUUID == null) ? 0 : serviceUUID.hashCode());
92 result = prime * result + ((serviceVersion == null) ? 0 : serviceVersion.hashCode());
97 public boolean equals(Object obj) {
104 if (getClass() != obj.getClass()) {
107 Service other = (Service) obj;
108 if (serviceInvariantUUID == null) {
109 if (other.serviceInvariantUUID != null) {
112 } else if (!serviceInvariantUUID.equals(other.serviceInvariantUUID)) {
115 if (serviceName == null) {
116 if (other.serviceName != null) {
119 } else if (!serviceName.equals(other.serviceName)) {
122 if (serviceUUID == null) {
123 if (other.serviceUUID != null) {
126 } else if (!serviceUUID.equals(other.serviceUUID)) {
129 if (serviceVersion == null) {
130 return other.serviceVersion == null;
132 return serviceVersion.equals(other.serviceVersion);