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