*/
package org.opendaylight.protocol.pcep.impl.object;
-import org.opendaylight.protocol.pcep.spi.EROSubobjectHandlerRegistry;
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
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.explicit.route.object.Ero;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.EroBuilder;
+import com.google.common.base.Preconditions;
+
/**
* Parser for {@link Ero}
*/
public static final int TYPE = 1;
- public PCEPExplicitRouteObjectParser(final EROSubobjectHandlerRegistry subobjReg) {
+ public PCEPExplicitRouteObjectParser(final EROSubobjectRegistry subobjReg) {
super(subobjReg);
}
@Override
- public Ero parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException {
- if (bytes == null || bytes.length == 0) {
- throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
- }
+ public Ero parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
+ Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final EroBuilder builder = new EroBuilder();
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
- builder.setSubobject(parseSubobjects(bytes));
+ builder.setSubobject(parseSubobjects(buffer));
return builder.build();
}
return ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(),
serializeSubobject(ero.getSubobject()));
}
-
- @Override
- public int getObjectType() {
- return TYPE;
- }
-
- @Override
- public int getObjectClass() {
- return CLASS;
- }
}