Get rid of JSR305 annotations
[bgpcep.git] / bgp / extensions / flowspec / src / main / java / org / opendaylight / protocol / bgp / flowspec / SimpleFlowspecIpv6NlriParser.java
1 /*
2  * Copyright (c) 2015 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.flowspec;
9
10 import io.netty.buffer.ByteBuf;
11 import java.util.List;
12 import org.opendaylight.protocol.bgp.flowspec.ipv6.FlowspecIpv6NlriParserHelper;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.Flowspec;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.FlowspecBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.FlowspecType;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.ipv6.DestinationFlowspecIpv6;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.ipv6.DestinationFlowspecIpv6Builder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
20 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
21
22 public final class SimpleFlowspecIpv6NlriParser extends AbstractFlowspecNlriParser {
23
24     public SimpleFlowspecIpv6NlriParser(final SimpleFlowspecTypeRegistry flowspecTypeRegistry) {
25         super(flowspecTypeRegistry);
26     }
27
28     @Override
29     public DestinationType createWithdrawnDestinationType(final Object[] nlriFields, final PathId pathId) {
30         final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[0];
31         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
32                 .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecIpv6CaseBuilder()
33             .setDestinationFlowspecIpv6(
34                 new DestinationFlowspecIpv6Builder()
35                     .setFlowspec(flowspecList)
36                     .setPathId(pathId)
37                     .build()
38             ).build();
39     }
40
41     @Override
42     public DestinationType createAdvertizedRoutesDestinationType(final Object[] nlriFields, final PathId pathId) {
43         final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[0];
44         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
45                 .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecIpv6CaseBuilder()
46             .setDestinationFlowspecIpv6(
47                 new DestinationFlowspecIpv6Builder()
48                     .setFlowspec(flowspecList)
49                     .setPathId(pathId)
50                     .build()
51             ).build();
52     }
53
54     @Override
55     public void extractSpecificFlowspec(final ChoiceNode fsType, final FlowspecBuilder fsBuilder) {
56         FlowspecIpv6NlriParserHelper.extractFlowspec(fsType, fsBuilder);
57     }
58
59     @Override
60     protected void stringSpecificFSNlriType(final FlowspecType value, final StringBuilder buffer) {
61         FlowspecIpv6NlriParserHelper.buildFlowspecString(value, buffer);
62     }
63
64     @Override
65     protected void serializeMpReachNlri(final DestinationType dstType, final ByteBuf byteAggregator) {
66         if (dstType instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329
67                 .update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecIpv6Case) {
68             final DestinationFlowspecIpv6 destFlowspec = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
69                     .yang.bgp.flowspec.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type
70                     .DestinationFlowspecIpv6Case) dstType).getDestinationFlowspecIpv6();
71             serializeNlri(new Object[] {destFlowspec.getFlowspec()}, destFlowspec.getPathId(), byteAggregator);
72         }
73     }
74
75     @Override
76     protected void serializeMpUnreachNlri(final DestinationType dstType, final ByteBuf byteAggregator) {
77         if (dstType instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329
78                 .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecIpv6Case) {
79             final DestinationFlowspecIpv6 destFlowspec = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
80                     .yang.bgp.flowspec.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
81                     .DestinationFlowspecIpv6Case) dstType).getDestinationFlowspecIpv6();
82             serializeNlri(new Object[] {destFlowspec.getFlowspec()}, destFlowspec.getPathId(), byteAggregator);
83         }
84     }
85 }
86