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
9 package org.opendaylight.protocol.bmp.impl.tlv;
11 import com.google.common.base.Preconditions;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException;
14 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvParser;
15 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvSerializer;
16 import org.opendaylight.protocol.bmp.spi.parser.TlvUtil;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.Tlv;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.stat.tlvs.InvalidatedClusterListLoopTlv;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.stat.tlvs.InvalidatedClusterListLoopTlvBuilder;
22 public class StatType003TlvHandler implements BmpTlvParser, BmpTlvSerializer {
24 public static final int TYPE = 3;
27 public void serializeTlv(final Tlv tlv, final ByteBuf output) {
28 Preconditions.checkArgument(tlv instanceof InvalidatedClusterListLoopTlv, "InvalidatedClusterListLoopTlv is mandatory.");
29 TlvUtil.formatTlvCounter32(TYPE, ((InvalidatedClusterListLoopTlv) tlv).getCount(), output);
33 public Tlv parseTlv(final ByteBuf buffer) throws BmpDeserializationException {
37 return new InvalidatedClusterListLoopTlvBuilder().setCount(new Counter32(buffer.readUnsignedInt())).build();