*/
package org.opendaylight.protocol.pcep.impl.object;
-import java.util.List;
-
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPObject;
-import org.opendaylight.protocol.pcep.impl.PCEPEROSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.PCEPObjectParser;
-import org.opendaylight.protocol.pcep.object.PCEPIncludeRouteObject;
-import org.opendaylight.protocol.pcep.subobject.ExplicitRouteSubobject;
+import org.opendaylight.protocol.pcep.PCEPDocumentedException;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
+import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.IncludeRouteObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.IncludeRouteBuilder;
/**
- * Parser for {@link org.opendaylight.protocol.pcep.object.PCEPIncludeRouteObject
- * PCEPIncludeRouteObject}
+ * Parser for {@link IncludeRouteObject}
*/
-public class PCEPIncludeRouteObjectParser implements PCEPObjectParser {
+public class PCEPIncludeRouteObjectParser extends AbstractObjectParser<IncludeRouteBuilder> {
+
+ public static final int CLASS = 10;
+
+ public static final int TYPE = 1;
+
+ public PCEPIncludeRouteObjectParser(final HandlerRegistry registry) {
+ super(registry);
+ }
@Override
- public PCEPObject parse(byte[] bytes, boolean processed, boolean ignored) throws PCEPDeserializerException {
+ public IncludeRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
+ PCEPDocumentedException {
if (bytes == null || bytes.length == 0)
throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
- final List<ExplicitRouteSubobject> subobjects = PCEPEROSubobjectParser.parse(bytes);
- if (subobjects.isEmpty())
- throw new PCEPDeserializerException("Empty Include Route Object.");
+ final IncludeRouteBuilder builder = new IncludeRouteBuilder();
- return new PCEPIncludeRouteObject(subobjects, processed, ignored);
+ builder.setIgnore(header.isIgnore());
+ builder.setProcessingRule(header.isProcessingRule());
+ // FIXME: add subobjects
+ return builder.build();
}
@Override
- public byte[] put(PCEPObject obj) {
- if (!(obj instanceof PCEPIncludeRouteObject))
- throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + obj.getClass() + ". Needed PCEPIncludeRouteObject.");
+ public void addTlv(final IncludeRouteBuilder builder, final Tlv tlv) {
+ // No tlvs defined
+ }
- assert !(((PCEPIncludeRouteObject) obj).getSubobjects().isEmpty()) : "Empty Include Route Object.";
+ @Override
+ public byte[] serializeObject(final Object object) {
+ if (!(object instanceof IncludeRouteObject))
+ throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed IncludeRouteObject.");
- return PCEPEROSubobjectParser.put(((PCEPIncludeRouteObject) obj).getSubobjects());
+ assert !(((IncludeRouteObject) object).getSubobjects().isEmpty()) : "Empty Include Route Object.";
+
+ // return PCEPEROSubobjectParser.put(((PCEPIncludeRouteObject) object).getSubobjects());
+ // FIXME add subobjects
+ return null;
+ }
+
+ @Override
+ public int getObjectType() {
+ return TYPE;
}
+ @Override
+ public int getObjectClass() {
+ return CLASS;
+ }
}