Fixed SupportedTables map.
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / BestPath.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.protocol.bgp.rib.impl;
9
10 import com.google.common.base.MoreObjects;
11 import com.google.common.base.MoreObjects.ToStringHelper;
12 import com.google.common.base.Preconditions;
13 import com.google.common.primitives.UnsignedInteger;
14 import javax.annotation.Nonnull;
15
16 final class BestPath {
17     private final UnsignedInteger routerId;
18     private final BestPathState state;
19
20     BestPath(@Nonnull final UnsignedInteger routerId, @Nonnull final BestPathState state) {
21         this.routerId = Preconditions.checkNotNull(routerId);
22         this.state = Preconditions.checkNotNull(state);
23     }
24
25     UnsignedInteger getRouterId() {
26         return this.routerId;
27     }
28
29     BestPathState getState() {
30         return this.state;
31     }
32
33     private ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
34         toStringHelper.add("routerId", this.routerId);
35         toStringHelper.add("state", this.state);
36         return toStringHelper;
37     }
38
39     @Override
40     public String toString() {
41         return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
42     }
43
44     @Override
45     public int hashCode() {
46         final int prime = 31;
47         int result = 1;
48         result = prime * result + this.routerId.hashCode();
49         result = prime * result + this.state.hashCode();
50         return result;
51     }
52
53     @Override
54     public boolean equals(final Object obj) {
55         if (this == obj) {
56             return true;
57         }
58         if (!(obj instanceof BestPath)) {
59             return false;
60         }
61         final BestPath other = (BestPath) obj;
62         if (!this.routerId.equals(other.routerId)) {
63             return false;
64         }
65         if (!this.state.equals(other.state)) {
66             return false;
67         }
68         return true;
69     }
70 }