blob: 1520c60fd37f21165502673ae0ee4c7557630434 [file] [log] [blame]
Jonathan Hartb39a67d2013-08-10 23:59:50 +12001package net.onrc.onos.ofcontroller.bgproute;
2
3import java.net.InetAddress;
Jonathan Hartabf10222013-08-13 10:19:34 +12004
5import com.google.common.net.InetAddresses;
Jonathan Hartb39a67d2013-08-10 23:59:50 +12006
7public class RibEntry {
Jonathan Hart08ee8522013-09-22 17:34:43 +12008 private final InetAddress routerId;
9 private final InetAddress nextHop;
Jonathan Hartb39a67d2013-08-10 23:59:50 +120010
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 Hartabf10222013-08-13 10:19:34 +120017 this.routerId = InetAddresses.forString(routerId);
18 this.nextHop = InetAddresses.forString(nextHop);
Jonathan Hartb39a67d2013-08-10 23:59:50 +120019 }
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}