2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.protocol.bgp.flowspec;
10 import io.netty.buffer.ByteBuf;
11 import io.netty.buffer.Unpooled;
12 import java.util.List;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.NumericOperand;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.NumericTwoByteValue;
17 * Parser class for NumericTwoByteValues.
19 public final class NumericTwoByteOperandParser extends AbstractNumericByteOperandParser<NumericTwoByteValue, Integer> {
21 public static final NumericTwoByteOperandParser INSTANCE;
24 INSTANCE = new NumericTwoByteOperandParser();
27 private NumericTwoByteOperandParser() {
32 * Serializes Flowspec component type that has maximum of 2B sized value field and numeric operand.
34 * @param list of operands to be serialized
35 * @param nlriByteBuf where the operands will be serialized
38 public <T extends NumericTwoByteValue> void serialize(final List<T> list, final ByteBuf nlriByteBuf) {
39 for (final T operand : list) {
40 final ByteBuf protoBuf = Unpooled.buffer();
41 Util.writeShortest(operand.getValue(), protoBuf);
42 super.serialize(operand.getOp(), protoBuf.readableBytes(), nlriByteBuf);
43 nlriByteBuf.writeBytes(protoBuf);
48 protected <T extends NumericTwoByteValue> Integer getValue(final T item) {
49 return item.getValue();
53 <T extends NumericTwoByteValue> NumericOperand getOp(final T item) {