blob: 9c47e64afb4794954ea4c8f1f87469bf8bed8896 [file] [log] [blame]
Ray Milkey2d572dd2017-04-14 10:01:24 -07001/*
Shravan Ambati7d199542016-04-22 16:09:05 -07002 * Copyright 2016-present Open Networking Laboratory
Ray Milkey2d572dd2017-04-14 10:01:24 -07003 *
Shravan Ambati7d199542016-04-22 16:09:05 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Ray Milkey2d572dd2017-04-14 10:01:24 -07007 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
Shravan Ambati7d199542016-04-22 16:09:05 -070010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.kafkaintegration.api.dto;
17
18import static com.google.common.base.MoreObjects.toStringHelper;
19import static com.google.common.base.Preconditions.checkNotNull;
20
21import java.util.Objects;
22import java.util.UUID;
23
24/**
25 * Wrapper Object for storing the consumer group id. Group ids are used by
26 * external applications when consuming events from Kafka server.
27 *
28 */
29public final class EventSubscriberGroupId {
30 private final UUID id;
31
32 /**
33 * Creates a new Subscriber Group Id.
34 *
35 * @param uuid representing the group id.
36 */
37 public EventSubscriberGroupId(UUID uuid) {
38 id = checkNotNull(uuid);
39 }
40
41 /**
42 * Returns the Group Id of the subscriber.
43 *
44 * @return uuid representing the group id.
45 */
46 public UUID getId() {
47 return id;
48 }
49
50 @Override
51 public boolean equals(Object o) {
52 if (o instanceof EventSubscriberGroupId) {
53 EventSubscriberGroupId sub = (EventSubscriberGroupId) o;
54 if (sub.id.equals(id)) {
55 return true;
56 }
57 }
58
59 return false;
60 }
61
62 @Override
63 public int hashCode() {
64 return Objects.hash(id);
65 }
66
67 @Override
68 public String toString() {
69 return toStringHelper(this).add("subscriberGroupId", id).toString();
70 }
71}