Get rid of JSR305 annotations
[bgpcep.git] / bgp / extensions / flowspec / src / main / java / org / opendaylight / protocol / bgp / flowspec / l3vpn / ipv6 / FlowspecL3vpnIpv6NlriParser.java
1 /*
2  * Copyright (c) 2016 Brocade Communications 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.flowspec.l3vpn.ipv6;
9
10 import io.netty.buffer.ByteBuf;
11 import java.util.List;
12 import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecTypeRegistry;
13 import org.opendaylight.protocol.bgp.flowspec.ipv6.FlowspecIpv6NlriParserHelper;
14 import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnNlriParser;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.Flowspec;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.FlowspecBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.FlowspecType;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6Builder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisher;
23 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
24
25 /**
26  * L3 VPN IPv6 flowspec parser.
27  *
28  * @author Kevin Wang
29  */
30 public final class FlowspecL3vpnIpv6NlriParser extends AbstractFlowspecL3vpnNlriParser {
31
32     public FlowspecL3vpnIpv6NlriParser(SimpleFlowspecTypeRegistry flowspecTypeRegistry) {
33         super(flowspecTypeRegistry);
34     }
35
36     @Override
37     public DestinationType createWithdrawnDestinationType(final Object[] nlriFields, final PathId pathId) {
38         final RouteDistinguisher rd = (RouteDistinguisher) nlriFields[0];
39         final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[1];
40         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
41                 .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6CaseBuilder()
42                 .setDestinationFlowspecL3vpnIpv6(new DestinationFlowspecL3vpnIpv6Builder()
43                     .setRouteDistinguisher(rd)
44                     .setFlowspec(flowspecList)
45                     .setPathId(pathId)
46                     .build()).build();
47     }
48
49     @Override
50     public DestinationType createAdvertizedRoutesDestinationType(final Object[] nlriFields, final PathId pathId) {
51         final RouteDistinguisher rd = (RouteDistinguisher) nlriFields[0];
52         final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[1];
53         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
54                 .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv6CaseBuilder()
55                 .setDestinationFlowspecL3vpnIpv6(new DestinationFlowspecL3vpnIpv6Builder()
56                     .setRouteDistinguisher(rd)
57                     .setFlowspec(flowspecList)
58                     .setPathId(pathId)
59                     .build()).build();
60     }
61
62     @Override
63     public void extractSpecificFlowspec(final ChoiceNode fsType, final FlowspecBuilder fsBuilder) {
64         FlowspecIpv6NlriParserHelper.extractFlowspec(fsType, fsBuilder);
65     }
66
67     @Override
68     protected void stringSpecificFSNlriType(final FlowspecType value, final StringBuilder buffer) {
69         FlowspecIpv6NlriParserHelper.buildFlowspecString(value, buffer);
70     }
71
72     @Override
73     protected void serializeMpReachNlri(final DestinationType dstType, final ByteBuf byteAggregator) {
74         if (dstType instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329
75                 .update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv6Case) {
76             final DestinationFlowspecL3vpnIpv6 destFlowspec = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
77                     .ns.yang.bgp.flowspec.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type
78                     .DestinationFlowspecL3vpnIpv6Case) dstType).getDestinationFlowspecL3vpnIpv6();
79             serializeNlri(
80                 new Object[] {
81                     destFlowspec.getRouteDistinguisher(),
82                     destFlowspec.getFlowspec()
83                 },
84                 destFlowspec.getPathId(),
85                 byteAggregator
86             );
87         }
88     }
89
90     @Override
91     protected void serializeMpUnreachNlri(final DestinationType dstType, final ByteBuf byteAggregator) {
92         if (dstType instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329
93                 .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6Case) {
94             final DestinationFlowspecL3vpnIpv6 destFlowspec = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
95                     .ns.yang.bgp.flowspec.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
96                     .DestinationFlowspecL3vpnIpv6Case) dstType).getDestinationFlowspecL3vpnIpv6();
97             serializeNlri(
98                 new Object[] {
99                     destFlowspec.getRouteDistinguisher(),
100                     destFlowspec.getFlowspec()
101                 },
102                 destFlowspec.getPathId(),
103                 byteAggregator
104             );
105         }
106     }
107 }