Bump MDSAL to 4.0.0
[bgpcep.git] / pcep / spi / src / main / java / org / opendaylight / protocol / pcep / spi / pojo / SimpleXROSubobjectRegistry.java
index cf6fdb9d08adc84d903fa1a03c3d458b6dcf5e03..f435aa4cfcfb8898d7635615a7cd7d1ed36fe8e0 100644 (file)
@@ -7,49 +7,52 @@
  */
 package org.opendaylight.protocol.pcep.spi.pojo;
 
-import io.netty.buffer.ByteBuf;
+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.XROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectRegistry;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
 import org.opendaylight.protocol.util.Values;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.SubobjectType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.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;
 
-import com.google.common.base.Preconditions;
-
 public final 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);
-               return this.handlers.registerParser(subobjectType, parser);
-       }
-
-       public AutoCloseable registerSubobjectSerializer(final Class<? extends SubobjectType> subobjectClass,
-                       final XROSubobjectSerializer serializer) {
-               return this.handlers.registerSerializer(subobjectClass, serializer);
-       }
-
-       @Override
-       public Subobject parseSubobject(final int type, final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException {
-               Preconditions.checkArgument(type >= 0 && type <= Values.UNSIGNED_SHORT_MAX_VALUE);
-               final XROSubobjectParser parser = this.handlers.getParser(type);
-               if (parser == null) {
-                       return null;
-               }
-               return parser.parseSubobject(buffer, mandatory);
-       }
-
-       @Override
-       public byte[] serializeSubobject(Subobject subobject) {
-               final XROSubobjectSerializer serializer = this.handlers.getSerializer(subobject.getSubobjectType().getImplementedInterface());
-               if (serializer == null) {
-                       return null;
-               }
-               return serializer.serializeSubobject(subobject);
-       }
+    private final HandlerRegistry<DataContainer, XROSubobjectParser, XROSubobjectSerializer> handlers =
+            new HandlerRegistry<>();
+
+    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 Registration registerSubobjectSerializer(final Class<? extends SubobjectType> subobjectClass,
+            final XROSubobjectSerializer serializer) {
+        return this.handlers.registerSerializer(subobjectClass, serializer);
+    }
+
+    @Override
+    public Subobject parseSubobject(final int type, final ByteBuf buffer, final boolean mandatory)
+            throws PCEPDeserializerException {
+        checkArgument(type >= 0 && type <= Values.UNSIGNED_SHORT_MAX_VALUE);
+        final XROSubobjectParser parser = this.handlers.getParser(type);
+        if (parser == null) {
+            return null;
+        }
+        return parser.parseSubobject(buffer, mandatory);
+    }
+
+    @Override
+    public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
+        final XROSubobjectSerializer serializer = this.handlers.getSerializer(
+            subobject.getSubobjectType().implementedInterface());
+        if (serializer == null) {
+            return;
+        }
+        serializer.serializeSubobject(subobject, buffer);
+    }
 }