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.XROSubobjectHandlerRegistry;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ExcludeRouteObject;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.svec.XroBuilder;
19 * Parser for {@link ExcludeRouteObject}
21 public final class PCEPExcludeRouteObjectParser extends AbstractXROWithSubobjectsParser {
23 public static final int CLASS = 7; // FIXME: to actual value
25 public static final int TYPE = 1;
27 public PCEPExcludeRouteObjectParser(final XROSubobjectHandlerRegistry registry) {
32 public ExcludeRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
33 PCEPDocumentedException {
34 if (bytes == null || bytes.length == 0)
35 throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
37 final XroBuilder builder = new XroBuilder();
39 builder.setIgnore(header.isIgnore());
40 builder.setProcessingRule(header.isProcessingRule());
41 builder.setSubobjects(parseSubobjects(bytes));
42 return builder.build();
46 public byte[] serializeObject(final Object object) {
47 if (!(object instanceof ExcludeRouteObject))
48 throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed ExcludeRouteObject.");
49 final ExcludeRouteObject obj = (ExcludeRouteObject) object;
50 assert !(obj.getSubobjects().isEmpty()) : "Empty Excluded Route Object.";
51 return serializeSubobject(obj.getSubobjects());
55 public int getObjectType() {
60 public int getObjectClass() {