*/
package org.opendaylight.protocol.pcep.spi.pojo;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.concepts.HandlerRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.TlvSerializer;
import org.opendaylight.protocol.util.Values;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.DataContainer;
public final class SimpleTlvRegistry implements TlvRegistry {
private final HandlerRegistry<DataContainer, TlvParser, TlvSerializer> handlers = new HandlerRegistry<>();
- public AutoCloseable registerTlvParser(final int tlvType, final TlvParser parser) {
- Preconditions.checkArgument(tlvType >= 0 && tlvType < Values.UNSIGNED_SHORT_MAX_VALUE);
+ public Registration registerTlvParser(final int tlvType, final TlvParser parser) {
+ checkArgument(tlvType >= 0 && tlvType < Values.UNSIGNED_SHORT_MAX_VALUE);
return this.handlers.registerParser(tlvType, parser);
}
- public AutoCloseable registerTlvSerializer(final Class<? extends Tlv> tlvClass, final TlvSerializer serializer) {
+ public Registration registerTlvSerializer(final Class<? extends Tlv> tlvClass, final TlvSerializer serializer) {
return this.handlers.registerSerializer(tlvClass, serializer);
}
@Override
public Tlv parseTlv(final int type, final ByteBuf buffer) throws PCEPDeserializerException {
- Preconditions.checkArgument(type >= 0 && type <= Values.UNSIGNED_SHORT_MAX_VALUE);
+ checkArgument(type >= 0 && type <= Values.UNSIGNED_SHORT_MAX_VALUE);
final TlvParser parser = this.handlers.getParser(type);
if (parser == null) {
return null;