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.rsvp.parser.impl.subobject.rro;
10 import com.google.common.base.Preconditions;
11 import io.netty.buffer.ByteBuf;
12 import io.netty.buffer.Unpooled;
13 import org.opendaylight.protocol.rsvp.parser.impl.te.ProtectionCommonParser;
14 import org.opendaylight.protocol.rsvp.parser.spi.RROSubobjectSerializer;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainer;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.record.route.subobjects.subobject.type.DynamicControlProtectionCase;
19 public class SRRODynamicProtectionSubobjectParser extends ProtectionCommonParser implements RROSubobjectSerializer {
20 public static final int TYPE = 37;
21 public static final short CTYPE = 2;
24 public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
25 Preconditions.checkArgument(subobject.getSubobjectType() instanceof DynamicControlProtectionCase,
26 "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType());
27 final ProtectionSubobject protObj = ((DynamicControlProtectionCase) subobject.getSubobjectType())
28 .getDynamicControlProtection().getProtectionSubobject();
29 final ByteBuf body = Unpooled.buffer();
30 serializeBody(CTYPE, protObj, body);
31 RROSubobjectUtil.formatSubobject(TYPE, body, buffer);