Enforce checkstyle in bgp-linkstate
[bgpcep.git] / bgp / extensions / linkstate / src / main / java / org / opendaylight / protocol / bgp / linkstate / impl / attribute / sr / Ipv6SrPrefixAttributesParser.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 package org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr;
9
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.prefix.state.Ipv6SrPrefix;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.prefix.state.Ipv6SrPrefixBuilder;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Algorithm;
14
15 public final class Ipv6SrPrefixAttributesParser {
16     private static final int FLAGS_SIZE = 2;
17
18     private Ipv6SrPrefixAttributesParser() {
19
20     }
21
22     public static Ipv6SrPrefix parseSrIpv6Prefix(final ByteBuf buffer) {
23         final Ipv6SrPrefixBuilder builder = new Ipv6SrPrefixBuilder();
24         buffer.skipBytes(FLAGS_SIZE);
25         builder.setAlgorithm(Algorithm.forValue(buffer.readUnsignedByte()));
26         return builder.build();
27     }
28
29     public static void serializePrefixAttributes(final Algorithm algorithm, final ByteBuf buffer) {
30         buffer.writeZero(FLAGS_SIZE);
31         buffer.writeByte(algorithm.getIntValue());
32     }
33
34     public static void serializeIpv6SrPrefix(final Ipv6SrPrefix ipv6SrPrefix, final ByteBuf buffer) {
35         serializePrefixAttributes(ipv6SrPrefix.getAlgorithm(), buffer);
36     }
37 }