Migrate AbstractRegistration/AutoCloseable
[bgpcep.git] / rsvp / spi / src / main / java / org / opendaylight / protocol / rsvp / parser / spi / pojo / SimpleXROSubobjectRegistry.java
index 658f3b0ac260d2be999735f6605952a5f10ab91c..9647d79e9a722ad3287a012eea96c967b50ec52c 100644 (file)
@@ -5,10 +5,10 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.protocol.rsvp.parser.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.rsvp.parser.spi.RSVPParsingException;
@@ -18,18 +18,19 @@ import org.opendaylight.protocol.rsvp.parser.spi.XROSubobjectSerializer;
 import org.opendaylight.protocol.util.Values;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainer;
+import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
 
 public class SimpleXROSubobjectRegistry implements XROSubobjectRegistry {
     private final HandlerRegistry<DataContainer, XROSubobjectParser, XROSubobjectSerializer> handlers =
         new HandlerRegistry<>();
 
-    public AutoCloseable registerSubobjectParser(final int subobjectType, final XROSubobjectParser parser) {
-        Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= Values.UNSIGNED_SHORT_MAX_VALUE);
+    public Registration registerSubobjectParser(final int subobjectType, final XROSubobjectParser parser) {
+        checkArgument(subobjectType >= 0 && subobjectType <= Values.UNSIGNED_SHORT_MAX_VALUE);
         return this.handlers.registerParser(subobjectType, parser);
     }
 
-    public AutoCloseable registerSubobjectSerializer(final Class<? extends SubobjectType> subobjectClass,
+    public Registration registerSubobjectSerializer(final Class<? extends SubobjectType> subobjectClass,
         final XROSubobjectSerializer serializer) {
         return this.handlers.registerSerializer(subobjectClass, serializer);
     }
@@ -37,7 +38,7 @@ public class SimpleXROSubobjectRegistry implements XROSubobjectRegistry {
     @Override
     public SubobjectContainer parseSubobject(final int type, final ByteBuf buffer, final boolean mandatory)
         throws RSVPParsingException {
-        Preconditions.checkArgument(type >= 0 && type <= Values.UNSIGNED_SHORT_MAX_VALUE);
+        checkArgument(type >= 0 && type <= Values.UNSIGNED_SHORT_MAX_VALUE);
         final XROSubobjectParser parser = this.handlers.getParser(type);
         if (parser == null) {
             return null;