2 * Copyright (c) 2013 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.pcep.ietf.stateful07;
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.protocol.pcep.parser.object.PCEPOpenObjectParser;
12 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
13 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.Tlvs1;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.Tlvs1Builder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.stateful.capability.tlv.Stateful;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.Tlvs;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
22 * Parser for Open object
24 public class Stateful07OpenObjectParser extends PCEPOpenObjectParser {
26 public Stateful07OpenObjectParser(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
27 super(tlvReg, viTlvReg);
31 public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
32 super.addTlv(tbuilder, tlv);
33 final Tlvs1Builder statefulBuilder = new Tlvs1Builder();
34 if (tbuilder.augmentation(Tlvs1.class) != null) {
35 final Tlvs1 t = tbuilder.augmentation(Tlvs1.class);
36 if (t.getStateful() != null) {
37 statefulBuilder.setStateful(t.getStateful());
40 if (tlv instanceof Stateful) {
41 statefulBuilder.setStateful((Stateful) tlv);
43 tbuilder.addAugmentation(Tlvs1.class, statefulBuilder.build());
47 public void serializeTlvs(final Tlvs tlvs, final ByteBuf body) {
51 super.serializeTlvs(tlvs, body);
52 if (tlvs.getOfList() != null) {
53 serializeTlv(tlvs.getOfList(), body);
55 if (tlvs.augmentation(Tlvs1.class) != null) {
56 final Tlvs1 statefulTlvs = tlvs.augmentation(Tlvs1.class);
57 if (statefulTlvs.getStateful() != null) {
58 serializeTlv(statefulTlvs.getStateful(), body);