Satish K | f6d87cb | 2015-11-30 19:59:22 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Satish K | f6d87cb | 2015-11-30 19:59:22 +0530 | [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.iptopology.api; |
| 17 | |
| 18 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 19 | |
| 20 | import java.util.Objects; |
| 21 | |
| 22 | import org.onlab.packet.IpPrefix; |
| 23 | |
| 24 | /** |
| 25 | * Provides information of IP address prefix in the IGP topology and a router advertises |
| 26 | * this to each of its BGP nexthop. |
| 27 | */ |
| 28 | public class IpReachability { |
| 29 | private final IpPrefix ipPrefix; |
| 30 | |
| 31 | /** |
| 32 | * Constructor to initialize IP prefix. |
| 33 | * |
| 34 | * @param ipPrefix IP address prefix |
| 35 | */ |
| 36 | public IpReachability(IpPrefix ipPrefix) { |
| 37 | this.ipPrefix = ipPrefix; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Provides IP Address prefix reachability. |
| 42 | * |
| 43 | * @return IP Address prefix |
| 44 | */ |
| 45 | public IpPrefix ipPrefix() { |
| 46 | return ipPrefix; |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public int hashCode() { |
| 51 | return Objects.hash(ipPrefix); |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public boolean equals(Object obj) { |
| 56 | if (this == obj) { |
| 57 | return true; |
| 58 | } |
| 59 | |
| 60 | if (obj instanceof IpReachability) { |
| 61 | IpReachability other = (IpReachability) obj; |
| 62 | return Objects.equals(ipPrefix, other.ipPrefix); |
| 63 | } |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public String toString() { |
| 69 | return toStringHelper(this) |
| 70 | .add("ipPrefix", ipPrefix) |
| 71 | .toString(); |
| 72 | } |
| 73 | } |