Upgrade ietf-{inet,yang}-types to 2013-07-15
[bgpcep.git] / rsvp / impl / src / main / java / org / opendaylight / protocol / rsvp / parser / impl / subobject / rro / SRRODynamicProtectionSubobjectParser.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.protocol.rsvp.parser.impl.subobject.rro;
10
11 import com.google.common.base.Preconditions;
12 import io.netty.buffer.ByteBuf;
13 import io.netty.buffer.Unpooled;
14 import org.opendaylight.protocol.rsvp.parser.impl.te.ProtectionCommonParser;
15 import org.opendaylight.protocol.rsvp.parser.spi.RROSubobjectSerializer;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainer;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.record.route.object.secondary.record.route.object.subobject.container.subobject.type.DynamicControlProtectionCase;
19
20 public class SRRODynamicProtectionSubobjectParser extends ProtectionCommonParser implements RROSubobjectSerializer {
21     public static final int TYPE = 37;
22     public static final Short CTYPE = 2;
23
24     @Override
25     public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
26         Preconditions.checkArgument(subobject.getSubobjectType() instanceof DynamicControlProtectionCase, "Unknown " +
27             "subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType());
28         final ProtectionSubobject protObj = ((DynamicControlProtectionCase) subobject.getSubobjectType())
29             .getDynamicControlProtection().getProtectionSubobject();
30         final ByteBuf body = Unpooled.buffer();
31         serializeBody(CTYPE, protObj, body);
32         RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
33     }
34 }