Enforce modernizer in openflowplugin-extension-onf 96/94396/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Jan 2021 10:25:22 +0000 (11:25 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Jan 2021 11:06:19 +0000 (12:06 +0100)
Fix the two violations we have and switch enforcement on.

Change-Id: I7b81271e6f4486072fa26fd62ad975c98b6e59ad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
extension/openflowplugin-extension-onf/pom.xml
extension/openflowplugin-extension-onf/src/main/java/org/opendaylight/openflowplugin/extension/onf/OnfExtensionProvider.java

index 6264b59cc373edf64738ac258e81265d74fe9d69..bf358ba4df835ee3eac0101db7dcb93bcb296d7c 100644 (file)
     <artifactId>openflowplugin-extension-onf</artifactId>
     <packaging>bundle</packaging>
 
-    <properties>
-        <!-- FIXME: Remove this -->
-        <odlparent.modernizer.enforce>false</odlparent.modernizer.enforce>
-    </properties>
-
     <dependencies>
         <dependency>
             <groupId>${project.groupId}</groupId>
index 0a881c3557a61ff4e388aef34d15f3fd05f88fb9..b5d252355f77cfcd55147956e3f2cfc2900cb78c 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.openflowplugin.extension.onf;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey;
@@ -36,20 +36,19 @@ import org.slf4j.LoggerFactory;
  * Main provider for ONF extensions.
  */
 public class OnfExtensionProvider {
-
     private static final Logger LOG = LoggerFactory.getLogger(OnfExtensionProvider.class);
 
-    private final SwitchConnectionProvider switchConnectionProvider;
-    private final ExtensionConverterRegistrator converterRegistrator;
-
     private static final BundleControlConverter BUNDLE_CONTROL_CONVERTER = new BundleControlConverter();
     private static final BundleAddMessageConverter BUNDLE_ADD_MESSAGE_CONVERTER = new BundleAddMessageConverter();
 
+    private final SwitchConnectionProvider switchConnectionProvider;
+    private final ExtensionConverterRegistrator converterRegistrator;
+
     public OnfExtensionProvider(final SwitchConnectionProvider switchConnectionProvider,
                                 final OpenFlowPluginExtensionRegistratorProvider converterRegistrator) {
-        this.switchConnectionProvider = Preconditions.checkNotNull(switchConnectionProvider,
+        this.switchConnectionProvider = requireNonNull(switchConnectionProvider,
                 "SwitchConnectionProvider can not be null!");
-        this.converterRegistrator = Preconditions.checkNotNull(converterRegistrator.getExtensionConverterRegistrator(),
+        this.converterRegistrator = requireNonNull(converterRegistrator.getExtensionConverterRegistrator(),
                 "ExtensionConverterRegistrator can not be null!");
     }
 
@@ -57,53 +56,34 @@ public class OnfExtensionProvider {
      * Init method for registration of converters called by blueprint.
      */
     public void init() {
-        registerSerializers();
-        registerDeserializers();
-        registerConverters();
-        LOG.info("ONF Extension Provider started.");
-    }
-
-    private void registerSerializers() {
         switchConnectionProvider.registerExperimenterMessageSerializer(
-                new ExperimenterIdTypeSerializerKey<>(OFConstants.OFP_VERSION_1_3,
-                                                      OnfConstants.ONF_EXPERIMENTER_ID_LONG,
-                                                      OnfConstants.ONF_ET_BUNDLE_CONTROL,
-                                                      ExperimenterDataOfChoice.class),
-                new BundleControlFactory());
+            new ExperimenterIdTypeSerializerKey<>(OFConstants.OFP_VERSION_1_3,
+                OnfConstants.ONF_EXPERIMENTER_ID_LONG, OnfConstants.ONF_ET_BUNDLE_CONTROL,
+                ExperimenterDataOfChoice.class), new BundleControlFactory());
         switchConnectionProvider.registerExperimenterMessageSerializer(
-                new ExperimenterIdTypeSerializerKey<>(OFConstants.OFP_VERSION_1_3,
-                                                      OnfConstants.ONF_EXPERIMENTER_ID_LONG,
-                                                      OnfConstants.ONF_ET_BUNDLE_ADD_MESSAGE,
-                                                      ExperimenterDataOfChoice.class),
-                new BundleAddMessageFactory());
-    }
-
+            new ExperimenterIdTypeSerializerKey<>(OFConstants.OFP_VERSION_1_3,
+                OnfConstants.ONF_EXPERIMENTER_ID_LONG, OnfConstants.ONF_ET_BUNDLE_ADD_MESSAGE,
+                ExperimenterDataOfChoice.class), new BundleAddMessageFactory());
 
-    private void registerDeserializers() {
         switchConnectionProvider.registerExperimenterMessageDeserializer(
-                new ExperimenterIdTypeDeserializerKey(OFConstants.OFP_VERSION_1_3,
-                                                      OnfConstants.ONF_EXPERIMENTER_ID_LONG,
-                                                      OnfConstants.ONF_ET_BUNDLE_CONTROL,
-                                                      ExperimenterDataOfChoice.class),
-                new org.opendaylight.openflowplugin.extension.onf.deserializer.BundleControlFactory());
+            new ExperimenterIdTypeDeserializerKey(OFConstants.OFP_VERSION_1_3,
+                OnfConstants.ONF_EXPERIMENTER_ID_LONG, OnfConstants.ONF_ET_BUNDLE_CONTROL,
+                ExperimenterDataOfChoice.class),
+            new org.opendaylight.openflowplugin.extension.onf.deserializer.BundleControlFactory());
         switchConnectionProvider.registerErrorDeserializer(
-                new ExperimenterIdDeserializerKey(OFConstants.OFP_VERSION_1_3,
-                                                  OnfConstants.ONF_EXPERIMENTER_ID_LONG,
-                                                  ErrorMessage.class),
-                new OnfExperimenterErrorFactory());
-    }
+            new ExperimenterIdDeserializerKey(OFConstants.OFP_VERSION_1_3,
+                OnfConstants.ONF_EXPERIMENTER_ID_LONG, ErrorMessage.class),
+            new OnfExperimenterErrorFactory());
 
-    private void registerConverters() {
         converterRegistrator.registerMessageConvertor(
-                new TypeVersionKey<>(BundleControlSal.class, OFConstants.OFP_VERSION_1_3), BUNDLE_CONTROL_CONVERTER);
+            new TypeVersionKey<>(BundleControlSal.class, OFConstants.OFP_VERSION_1_3), BUNDLE_CONTROL_CONVERTER);
         converterRegistrator.registerMessageConvertor(
-                new MessageTypeKey<>(OFConstants.OFP_VERSION_1_3, BundleControlOnf.class), BUNDLE_CONTROL_CONVERTER);
+            new MessageTypeKey<>(OFConstants.OFP_VERSION_1_3, BundleControlOnf.class), BUNDLE_CONTROL_CONVERTER);
         converterRegistrator.registerMessageConvertor(
-                new TypeVersionKey<>(BundleAddMessageSal.class, OFConstants.OFP_VERSION_1_3),
-                    BUNDLE_ADD_MESSAGE_CONVERTER);
+            new TypeVersionKey<>(BundleAddMessageSal.class, OFConstants.OFP_VERSION_1_3), BUNDLE_ADD_MESSAGE_CONVERTER);
         converterRegistrator.registerMessageConvertor(
-                new MessageTypeKey<>(OFConstants.OFP_VERSION_1_3, BundleAddMessageOnf.class),
-                    BUNDLE_ADD_MESSAGE_CONVERTER);
-    }
+            new MessageTypeKey<>(OFConstants.OFP_VERSION_1_3, BundleAddMessageOnf.class), BUNDLE_ADD_MESSAGE_CONVERTER);
 
+        LOG.info("ONF Extension Provider started.");
+    }
 }