Code clean up
[bgpcep.git] / bgp / extensions / mvpn / src / main / java / org / opendaylight / protocol / bgp / mvpn / impl / attributes / tunnel / identifier / BidirPimTreeParser.java
1 /*
2  * Copyright (c) 2016 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
9 package org.opendaylight.protocol.bgp.mvpn.impl.attributes.tunnel.identifier;
10
11 import io.netty.buffer.ByteBuf;
12 import org.opendaylight.protocol.bgp.mvpn.spi.attributes.tunnel.identifier.AbstractTunnelIdentifier;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.PmsiTunnelType;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.BidirPimTree;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.BidirPimTreeBuilder;
17
18 public final class BidirPimTreeParser extends AbstractTunnelIdentifier<BidirPimTree> {
19     public int getType() {
20         return PmsiTunnelType.BidirPimTree.getIntValue();
21     }
22
23     @Override
24     public int serialize(final BidirPimTree tunnelIdentifier, final ByteBuf buffer) {
25         PAddressPMulticastGroupUtil.serializeSenderPMulticastGroup(tunnelIdentifier.getBidirPimTree(), buffer);
26         return PmsiTunnelType.BidirPimTree.getIntValue();
27     }
28
29     @Override
30     public Class<? extends TunnelIdentifier> getClazz() {
31         return BidirPimTree.class;
32     }
33
34     @Override
35     public BidirPimTree parse(final ByteBuf buffer) {
36         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi
37                 .tunnel.tunnel.identifier.bidir.pim.tree.BidirPimTreeBuilder bidirPimTree =
38                 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel
39                         .pmsi.tunnel.tunnel.identifier.bidir.pim.tree.BidirPimTreeBuilder(PAddressPMulticastGroupUtil
40                         .parseSenderPMulticastGroup(buffer));
41         return new BidirPimTreeBuilder().setBidirPimTree(bidirPimTree.build()).build();
42     }
43 }