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.te;
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.spi.RROSubobjectRegistry;
14 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
15 import org.opendaylight.protocol.rsvp.parser.spi.subobjects.RROSubobjectListParser;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.object.RecordRouteObject;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.object.RecordRouteObjectBuilder;
20 public final class RecordRouteObjectParser extends RROSubobjectListParser {
21 public static final short CLASS_NUM = 21;
22 public static final short CTYPE = 1;
24 public RecordRouteObjectParser(final RROSubobjectRegistry subobjReg) {
29 protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
30 final RecordRouteObjectBuilder rro = new RecordRouteObjectBuilder();
31 return rro.setSubobjectContainer(parseList(byteBuf)).build();
35 public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) {
36 Preconditions.checkArgument(teLspObject instanceof RecordRouteObject, "RecordRouteObject is mandatory.");
37 final RecordRouteObject recordObject = (RecordRouteObject) teLspObject;
38 final ByteBuf bufferAux = Unpooled.buffer();
39 serializeList(recordObject.getSubobjectContainer(), bufferAux);
40 serializeAttributeHeader(bufferAux.readableBytes(), CLASS_NUM, CTYPE, output);
41 output.writeBytes(bufferAux);