Bump MDSAL to 4.0.0
[bgpcep.git] / pcep / spi / src / main / java / org / opendaylight / protocol / pcep / spi / pojo / SimpleEROSubobjectRegistry.java
index 1d8fe9d52b552d3966e17c0d9be27fa22ed28638..bcd50e57427794d2216070210a854f9e89d3f763 100644 (file)
@@ -7,10 +7,9 @@
  */
 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.EROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry;
@@ -19,24 +18,27 @@ import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.util.Values;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType;
+import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
 
 public final class SimpleEROSubobjectRegistry implements EROSubobjectRegistry {
-    private final HandlerRegistry<DataContainer, EROSubobjectParser, EROSubobjectSerializer> handlers = new HandlerRegistry<>();
+    private final HandlerRegistry<DataContainer, EROSubobjectParser, EROSubobjectSerializer> handlers =
+            new HandlerRegistry<>();
 
-    public AutoCloseable registerSubobjectParser(final int subobjectType, final EROSubobjectParser parser) {
-        Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= Values.UNSIGNED_SHORT_MAX_VALUE);
+    public Registration registerSubobjectParser(final int subobjectType, final EROSubobjectParser 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 EROSubobjectSerializer serializer) {
         return this.handlers.registerSerializer(subobjectClass, serializer);
     }
 
     @Override
-    public Subobject parseSubobject(final int type, final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException {
-        Preconditions.checkArgument(type >= 0 && type <= Values.UNSIGNED_SHORT_MAX_VALUE);
+    public Subobject parseSubobject(final int type, final ByteBuf buffer, final boolean loose)
+            throws PCEPDeserializerException {
+        checkArgument(type >= 0 && type <= Values.UNSIGNED_SHORT_MAX_VALUE);
         final EROSubobjectParser parser = this.handlers.getParser(type);
         if (parser == null) {
             return null;
@@ -46,7 +48,8 @@ public final class SimpleEROSubobjectRegistry implements EROSubobjectRegistry {
 
     @Override
     public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
-        final EROSubobjectSerializer serializer = this.handlers.getSerializer(subobject.getSubobjectType().getImplementedInterface());
+        final EROSubobjectSerializer serializer = this.handlers.getSerializer(
+            subobject.getSubobjectType().implementedInterface());
         if (serializer == null) {
             return;
         }