2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.protocol.bgp.mode.impl.base;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.base.MoreObjects.ToStringHelper;
13 import com.google.common.primitives.UnsignedInteger;
14 import javax.annotation.Nonnull;
15 import org.opendaylight.protocol.bgp.mode.api.BestPathState;
16 import org.opendaylight.protocol.bgp.mode.spi.AbstractBestPath;
17 import org.opendaylight.protocol.bgp.rib.spi.RouterIds;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerId;
20 final class BaseBestPath extends AbstractBestPath {
21 private static final long PATH_ID = 0;
22 private final UnsignedInteger routerId;
24 BaseBestPath(@Nonnull final UnsignedInteger routerId, @Nonnull final BestPathState state) {
26 this.routerId = requireNonNull(routerId);
30 public UnsignedInteger getRouterId() {
35 public PeerId getPeerId() {
36 return RouterIds.createPeerId(this.routerId);
40 public long getPathId() {
45 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
46 toStringHelper.add("routerId", this.routerId);
47 toStringHelper.add("state", this.state);
48 return toStringHelper;
52 public int hashCode() {
55 result = prime * result + this.routerId.hashCode();
56 result = prime * result + this.state.hashCode();
61 public boolean equals(final Object obj) {
65 if (!(obj instanceof BaseBestPath)) {
68 final BaseBestPath other = (BaseBestPath) obj;
69 if (!this.routerId.equals(other.routerId)) {
72 if (!this.state.equals(other.state)) {