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;
27 public class Service implements Serializable {
29 private static final long serialVersionUID = -1249276698549996806L;
31 private UUID serviceUUID;
32 private UUID serviceInvariantUUID;
33 private String serviceName;
34 private String serviceVersion;
40 public Service(UUID uuid) {
41 this.serviceUUID = uuid;
44 public Service(String name) {
45 this.serviceName = name;
51 * @param uuid service id
52 * @param invariantUUID service invariant id
54 * @param version version
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;
66 * @param service copy object
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;
75 public UUID getServiceUUID() {
79 public void setServiceUUID(UUID serviceUUID) {
80 this.serviceUUID = serviceUUID;
83 public UUID getServiceInvariantUUID() {
84 return serviceInvariantUUID;
87 public void setServiceInvariantUUID(UUID serviceInvariantUUID) {
88 this.serviceInvariantUUID = serviceInvariantUUID;
91 public String getServiceName() {
95 public void setServiceName(String serviceName) {
96 this.serviceName = serviceName;
99 public String getServiceVersion() {
100 return serviceVersion;
103 public void setServiceVersion(String serviceVersion) {
104 this.serviceVersion = serviceVersion;
108 public String toString() {
109 return "Service [serviceUUID=" + serviceUUID + ", serviceInvariantUUID=" + serviceInvariantUUID
110 + ", serviceName=" + serviceName + ", serviceVersion=" + serviceVersion + "]";
114 public int hashCode() {
115 final int prime = 31;
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());
125 public boolean equals(Object obj) {
132 if (getClass() != obj.getClass()) {
135 Service other = (Service) obj;
136 if (serviceInvariantUUID == null) {
137 if (other.serviceInvariantUUID != null) {
140 } else if (!serviceInvariantUUID.equals(other.serviceInvariantUUID)) {
143 if (serviceName == null) {
144 if (other.serviceName != null) {
147 } else if (!serviceName.equals(other.serviceName)) {
150 if (serviceUUID == null) {
151 if (other.serviceUUID != null) {
154 } else if (!serviceUUID.equals(other.serviceUUID)) {
157 if (serviceVersion == null) {
158 if (other.serviceVersion != null) {
161 } else if (!serviceVersion.equals(other.serviceVersion)) {