Get rid of JSR305 annotations
[bgpcep.git] / bgp / extensions / flowspec / src / main / java / org / opendaylight / protocol / bgp / flowspec / SimpleFlowspecIpv4NlriParser.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.ipv4.FlowspecIpv4NlriParserHelper;
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.ipv4.DestinationFlowspecIpv4;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.ipv4.DestinationFlowspecIpv4Builder;
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 SimpleFlowspecIpv4NlriParser extends AbstractFlowspecNlriParser {
23
24     public SimpleFlowspecIpv4NlriParser(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.DestinationFlowspecCaseBuilder()
33             .setDestinationFlowspecIpv4(
34                 new DestinationFlowspecIpv4Builder()
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.DestinationFlowspecCaseBuilder()
46                 .setDestinationFlowspecIpv4(new DestinationFlowspecIpv4Builder()
47                     .setFlowspec(flowspecList)
48                     .setPathId(pathId)
49                     .build()).build();
50     }
51
52     @Override
53     protected void serializeMpReachNlri(final DestinationType dstType, final ByteBuf byteAggregator) {
54         if (dstType instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329
55                 .update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecCase) {
56             final DestinationFlowspecIpv4 destFlowspec = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
57                     .yang.bgp.flowspec.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type
58                     .DestinationFlowspecCase) dstType).getDestinationFlowspecIpv4();
59             serializeNlri(new Object[] {destFlowspec.getFlowspec()}, destFlowspec.getPathId(), byteAggregator);
60         }
61     }
62
63     @Override
64     public void extractSpecificFlowspec(final ChoiceNode fsType, final FlowspecBuilder fsBuilder) {
65         FlowspecIpv4NlriParserHelper.extractFlowspec(fsType, fsBuilder);
66     }
67
68     @Override
69     protected void stringSpecificFSNlriType(final FlowspecType value, final StringBuilder buffer) {
70         FlowspecIpv4NlriParserHelper.buildFlowspecString(value, buffer);
71     }
72
73     @Override
74     protected void serializeMpUnreachNlri(final DestinationType dstType, final ByteBuf byteAggregator) {
75         if (dstType instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329
76                 .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCase) {
77             final DestinationFlowspecIpv4 destFlowspec = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
78                     .yang.bgp.flowspec.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
79                     .DestinationFlowspecCase) dstType).getDestinationFlowspecIpv4();
80             serializeNlri(new Object[] {destFlowspec.getFlowspec()}, destFlowspec.getPathId(), byteAggregator);
81         }
82     }
83 }
84