Migrate AbstractRegistration/AutoCloseable
[bgpcep.git] / pcep / spi / src / main / java / org / opendaylight / protocol / pcep / spi / pojo / SimpleTlvRegistry.java
index 1b718ef93f3426811ff50d3760e61588888cc050..d37b8cb07d66219e1049fe3d4d1be6733276dfd2 100644 (file)
@@ -7,7 +7,8 @@
  */
 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;
@@ -16,24 +17,25 @@ import org.opendaylight.protocol.pcep.spi.TlvRegistry;
 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;