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.handlers;
10 import io.netty.buffer.ByteBuf;
11 import java.util.Iterator;
12 import java.util.List;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.NumericOneByteValue;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.NumericOperand;
15 import org.opendaylight.yangtools.yang.common.Uint8;
18 * Parser class for NumericOneByteValues.
20 public final class NumericOneByteOperandParser extends AbstractNumericByteOperandParser<NumericOneByteValue, Uint8> {
22 public static final NumericOneByteOperandParser INSTANCE;
25 INSTANCE = new NumericOneByteOperandParser();
28 private NumericOneByteOperandParser() {
33 * Serializes Flowspec component type that has maximum of 1B sized value field and numeric operand.
35 * @param list of operands to be serialized
36 * @param nlriByteBuf where the operands will be serialized
39 public <T extends NumericOneByteValue> void serialize(final List<T> list, final ByteBuf nlriByteBuf) {
40 for (final Iterator<T> it = list.iterator(); it.hasNext(); ) {
41 final T operand = it.next();
42 super.serialize(operand.getOp(), 1, !it.hasNext(), nlriByteBuf);
43 Util.writeShortest(operand.getValue().toJava(), nlriByteBuf);
48 protected <T extends NumericOneByteValue> Uint8 getValue(final T item) {
49 return item.getValue();
53 <T extends NumericOneByteValue> NumericOperand getOp(final T item) {