Code clean up
[bgpcep.git] / bgp / mvpn / src / main / java / org / opendaylight / protocol / bgp / mvpn / impl / nlri / SharedTreeJoinHandler.java
1 /*
2  * Copyright (c) 2018 AT&T Intellectual Property. 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.nlri;
10
11 import io.netty.buffer.ByteBuf;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.NlriType;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.MvpnChoice;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.SharedTreeJoinCase;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.SharedTreeJoinCaseBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.shared.tree.join._case.SharedTreeJoinBuilder;
17
18 /**
19  * https://tools.ietf.org/html/rfc6514#section-4.6.
20  *
21  * @author Claudio D. Gasparini
22  */
23 public final class SharedTreeJoinHandler extends AbstractMvpnNlri<SharedTreeJoinCase> {
24     @Override
25     public int getType() {
26         return NlriType.SharedTreeJoin.getIntValue();
27     }
28
29     @Override
30     public SharedTreeJoinCase parseMvpn(final ByteBuf buffer) {
31         return new SharedTreeJoinCaseBuilder().setSharedTreeJoin(new SharedTreeJoinBuilder()
32                 .setCMulticast(CMulticastUtil.parseCMulticastGrouping(buffer))
33                 .build()).build();
34     }
35
36     @Override
37     protected ByteBuf serializeBody(final SharedTreeJoinCase mvpn) {
38         return CMulticastUtil.serializeCMulticast(mvpn.getSharedTreeJoin().getCMulticast());
39     }
40
41     @Override
42     public Class<? extends MvpnChoice> getClazz() {
43         return SharedTreeJoinCase.class;
44     }
45 }