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.parser;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.BgpTableType;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily;
14 import com.google.common.base.Preconditions;
17 * Utility class identifying a BGP table type. A table type is formed by two identifiers: AFI and SAFI.
19 public final class BgpTableTypeImpl implements BgpTableType {
21 private final Class<? extends SubsequentAddressFamily> safi;
23 private final Class<? extends AddressFamily> afi;
26 * Creates BGP Table type.
28 * @param afi Address Family Identifier
29 * @param safi Subsequent Address Family Identifier
31 public BgpTableTypeImpl(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
32 this.afi = Preconditions.checkNotNull(afi, "Address family may not be null");
33 this.safi = Preconditions.checkNotNull(safi, "Subsequent address family may not be null");
37 public Class<BgpTableType> getImplementedInterface() {
38 return BgpTableType.class;
42 public int hashCode() {
43 int ret = 3 * this.afi.hashCode();
44 ret += this.safi.hashCode();
49 public boolean equals(final Object obj) {
50 if (obj instanceof BgpTableTypeImpl) {
51 final BgpTableTypeImpl o = (BgpTableTypeImpl) obj;
52 return this.afi.equals(o.afi) && this.safi.equals(o.safi);
58 public String toString() {
59 return this.afi.toString() + "." + this.safi.toString();
63 * Returns Address Family Identifier.
68 public Class<? extends AddressFamily> getAfi() {
73 * Returns Subsequent Address Family Identifier.
78 public Class<? extends SubsequentAddressFamily> getSafi() {