Search in sources :

Example 1 with SrAlgorithmBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.state.SrAlgorithmBuilder in project bgpcep by opendaylight.

the class SrNodeAttributesParser method parseSrAlgorithms.

public static SrAlgorithm parseSrAlgorithms(final ByteBuf buffer) {
    final SrAlgorithmBuilder builder = new SrAlgorithmBuilder();
    final List<Algorithm> algs = new ArrayList<>();
    while (buffer.isReadable()) {
        algs.add(Algorithm.forValue(buffer.readUnsignedByte()));
    }
    builder.setAlgorithms(algs);
    return builder.build();
}
Also used : ArrayList(java.util.ArrayList) SrAlgorithmBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.state.SrAlgorithmBuilder) Algorithm(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.Algorithm) SrAlgorithm(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.state.SrAlgorithm)

Example 2 with SrAlgorithmBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.state.SrAlgorithmBuilder in project bgpcep by opendaylight.

the class SrAttributeParserTest method testSrAlgorithm.

@Test
public void testSrAlgorithm() {
    final byte[] bytes = { 0 };
    final SrAlgorithm alg = new SrAlgorithmBuilder().setAlgorithms(Lists.newArrayList(Algorithm.ShortestPathFirst)).build();
    final SrAlgorithm empty = new SrAlgorithmBuilder().setAlgorithms(Collections.emptyList()).build();
    assertEquals(alg, SrNodeAttributesParser.parseSrAlgorithms(Unpooled.wrappedBuffer(bytes)));
    final ByteBuf b = Unpooled.buffer();
    assertEquals(empty, SrNodeAttributesParser.parseSrAlgorithms(b));
    SrNodeAttributesParser.serializeSrAlgorithms(alg, b);
    assertArrayEquals(bytes, ByteArray.readAllBytes(b));
    SrNodeAttributesParser.serializeSrAlgorithms(empty, b);
    assertEquals(0, b.readableBytes());
}
Also used : SrAlgorithmBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.state.SrAlgorithmBuilder) ByteBuf(io.netty.buffer.ByteBuf) SrAlgorithm(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.state.SrAlgorithm) Test(org.junit.Test)

Aggregations

SrAlgorithm (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.state.SrAlgorithm)2 SrAlgorithmBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.state.SrAlgorithmBuilder)2 ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Algorithm (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.Algorithm)1