2 * Copyright (c) 2013 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.concepts;
10 import org.opendaylight.protocol.concepts.Identifier;
11 import com.google.common.base.Preconditions;
14 * Utility class identifying a BGP table type. A table type is formed by two identifiers: AFI and SAFI.
16 public final class BGPTableType implements Comparable<BGPTableType>, Identifier {
18 private static final long serialVersionUID = -5502662876916458740L;
20 private final BGPSubsequentAddressFamily safi;
22 private final BGPAddressFamily afi;
25 * Creates BGP Table type.
27 * @param afi Address Family Identifier
28 * @param safi Subsequent Address Family Identifier
30 public BGPTableType(final BGPAddressFamily afi, final BGPSubsequentAddressFamily safi) {
31 this.afi = Preconditions.checkNotNull(afi, "Address family may not be null");
32 this.safi = Preconditions.checkNotNull(safi, "Subsequent address family may not be null");
36 * Returns Address Family Identifier.
40 public BGPAddressFamily getAddressFamily() {
45 * Returns Subsequent Address Family Identifier.
49 public BGPSubsequentAddressFamily getSubsequentAddressFamily() {
54 public int hashCode() {
55 int ret = 3 * this.afi.hashCode();
56 ret += this.safi.hashCode();
61 public boolean equals(final Object obj) {
62 if (obj != null && obj instanceof BGPTableType) {
63 final BGPTableType o = (BGPTableType) obj;
64 return this.afi.equals(o.afi) && this.safi.equals(o.safi);
70 public int compareTo(final BGPTableType other) {
74 final int c = this.afi.compareTo(other.afi);
77 return this.safi.compareTo(other.safi);
81 public String toString() {
82 return this.afi.toString() + "." + this.safi.toString();