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.impl.object;
10 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
11 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
12 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
13 import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
14 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReportedRouteObject;
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.pcreq.message.pcreq.message.requests.segment.computation.p2p.ReportedRouteBuilder;
22 * Parser for {@link ReportedRouteObject}
24 public class PCEPReportedRouteObjectParser extends AbstractObjectParser<ReportedRouteBuilder> {
26 public static final int CLASS = 8;
28 public static final int TYPE = 1;
30 public PCEPReportedRouteObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
31 super(subobjReg, tlvReg);
35 public ReportedRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
36 PCEPDocumentedException {
37 if (bytes == null || bytes.length == 0) {
38 throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
41 final ReportedRouteBuilder builder = new ReportedRouteBuilder();
43 builder.setIgnore(header.isIgnore());
44 builder.setProcessingRule(header.isProcessingRule());
45 // FIXME: add subobjects
46 return builder.build();
50 public void addTlv(final ReportedRouteBuilder builder, final Tlv tlv) {
55 public byte[] serializeObject(final Object object) {
56 if (!(object instanceof ReportedRouteObject)) {
57 throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass()
58 + ". Needed ReportedRouteObject.");
61 assert !(((ReportedRouteObject) object).getSubobjects().isEmpty()) : "Empty Reported Route Object.";
62 // FIXME add subobjects
63 // return PCEPRROSubobjectParser.put(((ReportedRouteObject) object).getSubobjects());
68 public int getObjectType() {
73 public int getObjectClass() {