Code clean up
[bgpcep.git] / bgp / mvpn / src / main / java / org / opendaylight / protocol / bgp / mvpn / impl / nlri / SourceTreeJoinHandler.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.SourceTreeJoinCase;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.SourceTreeJoinCaseBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.source.tree.join._case.SourceTreeJoinBuilder;
17
18 /**
19  * https://tools.ietf.org/html/rfc6514#section-4.6.
20  *
21  * @author Claudio D. Gasparini
22  */
23 public final class SourceTreeJoinHandler extends AbstractMvpnNlri<SourceTreeJoinCase> {
24     @Override
25     public int getType() {
26         return NlriType.SourceTreeJoin.getIntValue();
27     }
28
29     @Override
30
31     public SourceTreeJoinCase parseMvpn(final ByteBuf buffer) {
32         return new SourceTreeJoinCaseBuilder().setSourceTreeJoin(
33                 new SourceTreeJoinBuilder().setCMulticast(CMulticastUtil.parseCMulticastGrouping(buffer))
34                         .build()).build();
35     }
36
37     @Override
38     protected ByteBuf serializeBody(final SourceTreeJoinCase mvpn) {
39         return CMulticastUtil.serializeCMulticast(mvpn.getSourceTreeJoin().getCMulticast());
40     }
41
42     @Override
43     public Class<? extends MvpnChoice> getClazz() {
44         return SourceTreeJoinCase.class;
45     }
46 }