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.pcep.sync.optimizations;
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07OpenObjectParser;
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.controller.pcep.sync.optimizations.rev150714.Tlvs3;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Tlvs3Builder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.lsp.db.version.tlv.LspDbVersion;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.speaker.entity.id.tlv.SpeakerEntityId;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.Tlvs;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
22 public class SyncOptimizationsOpenObjectParser extends Stateful07OpenObjectParser {
24 public SyncOptimizationsOpenObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
25 super(tlvReg, viTlvReg);
30 public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
31 super.addTlv(tbuilder, tlv);
32 final Tlvs3Builder syncOptTlvsBuilder = new Tlvs3Builder();
33 if (tbuilder.getAugmentation(Tlvs3.class) != null) {
34 final Tlvs3 t = tbuilder.getAugmentation(Tlvs3.class);
35 if (t.getLspDbVersion() != null) {
36 syncOptTlvsBuilder.setLspDbVersion(t.getLspDbVersion());
38 if (t.getSpeakerEntityId() != null) {
39 syncOptTlvsBuilder.setSpeakerEntityId(t.getSpeakerEntityId());
42 if (tlv instanceof LspDbVersion) {
43 syncOptTlvsBuilder.setLspDbVersion((LspDbVersion) tlv);
45 if (tlv instanceof SpeakerEntityId) {
46 syncOptTlvsBuilder.setSpeakerEntityId((SpeakerEntityId) tlv);
48 tbuilder.addAugmentation(Tlvs3.class, syncOptTlvsBuilder.build());
52 public void serializeTlvs(final Tlvs tlvs, final ByteBuf body) {
56 super.serializeTlvs(tlvs, body);
57 if (tlvs.getAugmentation(Tlvs3.class) != null) {
58 final Tlvs3 syncOptTlvs = tlvs.getAugmentation(Tlvs3.class);
59 if (syncOptTlvs.getLspDbVersion() != null) {
60 serializeTlv(syncOptTlvs.getLspDbVersion(), body);
62 if (syncOptTlvs.getSpeakerEntityId() != null) {
63 serializeTlv(syncOptTlvs.getSpeakerEntityId(), body);