Create common parent for extensions families
[bgpcep.git] / bgp / extensions / inet / src / main / java / org / opendaylight / protocol / bgp / inet / codec / nexthop / Ipv6NextHopParserSerializer.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
9 package org.opendaylight.protocol.bgp.inet.codec.nexthop;
10
11 import com.google.common.base.Preconditions;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.bgp.concepts.NextHopUtil;
14 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
15 import org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.CNextHop;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv6NextHopCase;
18
19 public final class Ipv6NextHopParserSerializer implements NextHopParserSerializer {
20     @Override
21     public CNextHop parseNextHop(final ByteBuf buffer) throws BGPParsingException {
22         return NextHopUtil.parseNextHop(buffer);
23
24     }
25
26     @Override
27     public void serializeNextHop(final CNextHop nextHop, final ByteBuf byteAggregator) {
28         Preconditions.checkArgument(nextHop instanceof Ipv6NextHopCase,
29                 "cNextHop is not a Ipv6 NextHop object.");
30         NextHopUtil.serializeNextHop(nextHop, byteAggregator);
31     }
32 }