Shravan Ambati | 5a11e17 | 2016-07-21 15:55:28 -0700 | [diff] [blame] | 1 | /** |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame^] | 2 | * Copyright 2016-present Open Networking Foundation |
Shravan Ambati | 5a11e17 | 2016-07-21 15:55:28 -0700 | [diff] [blame] | 3 | * |
| 4 | * 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 |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * 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 | */ |
| 16 | package org.onosproject.kafkaintegration.api.dto; |
| 17 | |
| 18 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 19 | |
| 20 | import java.util.Objects; |
| 21 | |
| 22 | /** |
| 23 | * DTO to hold Registration Response for requests from external apps. |
| 24 | */ |
| 25 | public final class RegistrationResponse { |
| 26 | |
| 27 | private EventSubscriberGroupId groupId; |
| 28 | |
| 29 | private String ipAddress; |
| 30 | |
| 31 | private String port; |
| 32 | |
| 33 | public RegistrationResponse(EventSubscriberGroupId groupId, |
| 34 | String ipAddress, String port) { |
| 35 | this.groupId = groupId; |
| 36 | this.ipAddress = ipAddress; |
| 37 | this.port = port; |
| 38 | } |
| 39 | |
| 40 | public final EventSubscriberGroupId getGroupId() { |
| 41 | return groupId; |
| 42 | } |
| 43 | |
| 44 | public final String getIpAddress() { |
| 45 | return ipAddress; |
| 46 | } |
| 47 | |
| 48 | public final String getPort() { |
| 49 | return port; |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | public boolean equals(Object o) { |
| 54 | if (o instanceof RegistrationResponse) { |
| 55 | RegistrationResponse sub = (RegistrationResponse) o; |
| 56 | if (sub.groupId.equals(groupId) && sub.ipAddress.equals(ipAddress) |
| 57 | && sub.port.equals(port)) { |
| 58 | return true; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public int hashCode() { |
| 67 | return Objects.hash(groupId, ipAddress, port); |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public String toString() { |
| 72 | return toStringHelper(this).add("subscriberGroupId", groupId) |
| 73 | .add("ipAddress", ipAddress).add("port", port).toString(); |
| 74 | } |
| 75 | } |