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.HandlerRegistry;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.IncludeRouteObject;
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.Tlv;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.IncludeRouteBuilder;
21 * Parser for {@link IncludeRouteObject}
23 public class PCEPIncludeRouteObjectParser extends AbstractObjectParser<IncludeRouteBuilder> {
25 public static final int CLASS = 10;
27 public static final int TYPE = 1;
29 public PCEPIncludeRouteObjectParser(final HandlerRegistry registry) {
34 public IncludeRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
35 PCEPDocumentedException {
36 if (bytes == null || bytes.length == 0)
37 throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
39 final IncludeRouteBuilder builder = new IncludeRouteBuilder();
41 builder.setIgnore(header.isIgnore());
42 builder.setProcessingRule(header.isProcessingRule());
43 // FIXME: add subobjects
44 return builder.build();
48 public void addTlv(final IncludeRouteBuilder builder, final Tlv tlv) {
53 public byte[] serializeObject(final Object object) {
54 if (!(object instanceof IncludeRouteObject))
55 throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed IncludeRouteObject.");
57 assert !(((IncludeRouteObject) object).getSubobjects().isEmpty()) : "Empty Include Route Object.";
59 // return PCEPEROSubobjectParser.put(((PCEPIncludeRouteObject) object).getSubobjects());
60 // FIXME add subobjects
65 public int getObjectType() {
70 public int getObjectClass() {