Jonathan Hart | b39a67d | 2013-08-10 23:59:50 +1200 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.bgproute; |
| 2 | |
| 3 | import java.net.InetAddress; |
Jonathan Hart | abf1022 | 2013-08-13 10:19:34 +1200 | [diff] [blame] | 4 | |
| 5 | import com.google.common.net.InetAddresses; |
Jonathan Hart | b39a67d | 2013-08-10 23:59:50 +1200 | [diff] [blame] | 6 | |
| 7 | public class RibEntry { |
Jonathan Hart | 08ee852 | 2013-09-22 17:34:43 +1200 | [diff] [blame^] | 8 | private final InetAddress routerId; |
| 9 | private final InetAddress nextHop; |
Jonathan Hart | b39a67d | 2013-08-10 23:59:50 +1200 | [diff] [blame] | 10 | |
| 11 | public RibEntry(InetAddress routerId, InetAddress nextHop) { |
| 12 | this.routerId = routerId; |
| 13 | this.nextHop = nextHop; |
| 14 | } |
| 15 | |
| 16 | public RibEntry(String routerId, String nextHop) { |
Jonathan Hart | abf1022 | 2013-08-13 10:19:34 +1200 | [diff] [blame] | 17 | this.routerId = InetAddresses.forString(routerId); |
| 18 | this.nextHop = InetAddresses.forString(nextHop); |
Jonathan Hart | b39a67d | 2013-08-10 23:59:50 +1200 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | public InetAddress getNextHop() { |
| 22 | return nextHop; |
| 23 | } |
| 24 | |
| 25 | @Override |
| 26 | public boolean equals(Object other) { |
| 27 | if (other == null || !(other instanceof RibEntry)) { |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | RibEntry otherRibEntry = (RibEntry) other; |
| 32 | |
| 33 | return this.routerId.equals(otherRibEntry.routerId) |
| 34 | && this.nextHop.equals(otherRibEntry.nextHop); |
| 35 | } |
| 36 | |
| 37 | @Override |
| 38 | public int hashCode() { |
| 39 | int hash = 17; |
| 40 | hash = 31 * hash + routerId.hashCode(); |
| 41 | hash = 31 * hash + nextHop.hashCode(); |
| 42 | return hash; |
| 43 | } |
| 44 | } |