moved BGP Table type from concepts to parser-api.
[bgpcep.git] / bgp / parser-api / src / main / java / org / opendaylight / protocol / bgp / parser / parameter / MultiprotocolCapability.java
1 /*
2  * Copyright (c) 2013 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.parser.parameter;
9
10 import org.opendaylight.protocol.bgp.parser.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;
13
14 /**
15  * Multiprotocol capability Parameter as described in:
16  * 
17  * <a href="http://tools.ietf.org/html/rfc4760#section-8">Use of BGP Capability Advertisement/a>
18  */
19 public final class MultiprotocolCapability extends CapabilityParameter {
20
21         /**
22          * Capability Code is set to 1, which indicates Multiprotocol Extensions capabilities.
23          */
24         public static final int CODE = 1;
25
26         private final BGPTableType tableType;
27
28         /**
29          * Creates Multiprotocol Capability.
30          * 
31          * 
32          * @param type bgp table type
33          */
34         public MultiprotocolCapability(final BGPTableType type) {
35                 super(CODE);
36                 this.tableType = type;
37         }
38
39         /**
40          * Returns numeric representation of AFI.
41          * 
42          * @return AFI
43          */
44         public Class<? extends AddressFamily> getAfi() {
45                 return this.tableType.getAddressFamily();
46         }
47
48         /**
49          * Returns numeric representation of SAFI.
50          * 
51          * @return SAFI
52          */
53         public Class<? extends SubsequentAddressFamily> getSafi() {
54                 return this.tableType.getSubsequentAddressFamily();
55         }
56
57         /**
58          * Returns BGP Table Type that is supported by the sender of this capability.
59          * 
60          * @return BGP Table Type
61          */
62         public BGPTableType getTableType() {
63                 return this.tableType;
64         }
65
66         /* (non-Javadoc)
67          * @see java.lang.Object#toString()
68          */
69         @Override
70         public String toString() {
71                 final StringBuilder builder = new StringBuilder();
72                 builder.append("MultiprotocolCapability [tableType=");
73                 builder.append(this.tableType);
74                 builder.append("]");
75                 return builder.toString();
76         }
77 }