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 int hashCode() {
38 int ret = 3 * this.afi.hashCode();
39 ret += this.safi.hashCode();
44 public boolean equals(final Object obj) {
45 if (obj != null && obj instanceof BgpTableTypeImpl) {
46 final BgpTableTypeImpl o = (BgpTableTypeImpl) obj;
47 return this.afi.equals(o.afi) && this.safi.equals(o.safi);
53 public String toString() {
54 return this.afi.toString() + "." + this.safi.toString();
58 * Returns Address Family Identifier.
63 public Class<? extends AddressFamily> getAfi() {
68 * Returns Subsequent Address Family Identifier.
73 public Class<? extends SubsequentAddressFamily> getSafi() {