Code clean up
[bgpcep.git] / bgp / extensions / mvpn / src / main / java / org / opendaylight / protocol / bgp / mvpn / impl / attributes / tunnel / identifier / IngressReplicationParser.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 static org.opendaylight.protocol.bgp.mvpn.impl.attributes.tunnel.identifier.PAddressPMulticastGroupUtil.parseIpAddress;
12 import static org.opendaylight.protocol.bgp.mvpn.impl.attributes.tunnel.identifier.PAddressPMulticastGroupUtil.serializeIpAddress;
13
14 import io.netty.buffer.ByteBuf;
15 import org.opendaylight.protocol.bgp.mvpn.spi.attributes.tunnel.identifier.AbstractTunnelIdentifier;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.PmsiTunnelType;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.IngressReplication;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.IngressReplicationBuilder;
20
21 public final class IngressReplicationParser extends AbstractTunnelIdentifier<IngressReplication> {
22     @Override
23     public int serialize(final IngressReplication tunnelIdentifier, final ByteBuf buffer) {
24         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi
25                 .tunnel.tunnel.identifier.ingress.replication.IngressReplication ingressReplication =
26                 tunnelIdentifier.getIngressReplication();
27         serializeIpAddress(ingressReplication.getReceivingEndpointAddress(), buffer);
28         return getType();
29     }
30
31     @Override
32     public Class<? extends TunnelIdentifier> getClazz() {
33         return IngressReplication.class;
34     }
35
36     @Override
37     public IngressReplication parse(final ByteBuf buffer) {
38         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi
39                 .tunnel.tunnel.identifier.ingress.replication.IngressReplication builder =
40                 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel
41                         .pmsi.tunnel.tunnel.identifier.ingress.replication.IngressReplicationBuilder()
42                         .setReceivingEndpointAddress(parseIpAddress(buffer.readableBytes(), buffer)).build();
43         return new IngressReplicationBuilder().setIngressReplication(builder).build();
44     }
45
46     @Override
47     public int getType() {
48         return PmsiTunnelType.IngressReplication.getIntValue();
49     }
50 }