From: Robert Varga Date: Tue, 2 May 2023 17:15:57 +0000 (+0200) Subject: Enforce modernize in openflowjava-extension-eric X-Git-Tag: release/potassium~10 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=f3a5966392b79ff8db678b170d83b4b4bdceb40f;p=openflowplugin.git Enforce modernize in openflowjava-extension-eric We have a few violations here -- migrate to using Math.toIntExact() and Objects.requireNonNull(). Flip enforcement on. Change-Id: I0a581d20b4cfb27489d1d09ac757cf17b22485d7 Signed-off-by: Robert Varga --- diff --git a/extension/openflowjava-extension-eric/pom.xml b/extension/openflowjava-extension-eric/pom.xml index 329c6a2a90..56d2146e61 100644 --- a/extension/openflowjava-extension-eric/pom.xml +++ b/extension/openflowjava-extension-eric/pom.xml @@ -11,11 +11,6 @@ openflowjava-extension-eric bundle - - - false - - ${project.groupId}.openflowjava diff --git a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/EricExtensionsRegistrator.java b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/EricExtensionsRegistrator.java index c9830e2fc1..879764134b 100644 --- a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/EricExtensionsRegistrator.java +++ b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/EricExtensionsRegistrator.java @@ -7,7 +7,8 @@ */ package org.opendaylight.openflowjava.eric; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import org.opendaylight.openflowjava.eric.api.EricExtensionCodecRegistrator; import org.opendaylight.openflowjava.eric.codec.match.Icmpv6NDOptionsTypeCodec; import org.opendaylight.openflowjava.eric.codec.match.Icmpv6NDReservedCodec; @@ -15,8 +16,8 @@ import org.opendaylight.openflowjava.eric.codec.match.Icmpv6NDReservedCodec; public class EricExtensionsRegistrator implements AutoCloseable { private final EricExtensionCodecRegistrator registrator; - public EricExtensionsRegistrator(EricExtensionCodecRegistrator registrator) { - this.registrator = Preconditions.checkNotNull(registrator); + public EricExtensionsRegistrator(final EricExtensionCodecRegistrator registrator) { + this.registrator = requireNonNull(registrator); registrator.registerMatchEntrySerializer(Icmpv6NDReservedCodec.SERIALIZER_KEY, Icmpv6NDReservedCodec.INSTANCE); registrator.registerMatchEntrySerializer(Icmpv6NDOptionsTypeCodec.SERIALIZER_KEY, diff --git a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/EricHeader.java b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/EricHeader.java index c75f0388da..69565172ca 100644 --- a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/EricHeader.java +++ b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/EricHeader.java @@ -7,8 +7,6 @@ */ package org.opendaylight.openflowjava.eric.codec.match; -import com.google.common.primitives.Ints; - /** * Eric header. */ @@ -21,11 +19,11 @@ public class EricHeader { private final int length; public EricHeader(final long header) { - this.headerAsLong = header; - this.oxmClass = Ints.checkedCast(extractSub(header, 16, 16)); - this.ericField = Ints.checkedCast(extractSub(header, 7, 9)); - this.hasMask = extractSub(header, 1, 8) == 1; - this.length = Ints.checkedCast(extractSub(header, 8, 0)); + headerAsLong = header; + oxmClass = Math.toIntExact(extractSub(header, 16, 16)); + ericField = Math.toIntExact(extractSub(header, 7, 9)); + hasMask = extractSub(header, 1, 8) == 1; + length = Math.toIntExact(extractSub(header, 8, 0)); } public EricHeader(final int oxmClass, final int ericField, final boolean hasMask, final int length) { @@ -33,7 +31,7 @@ public class EricHeader { this.ericField = ericField; this.hasMask = hasMask; this.length = length; - this.headerAsLong = (long) oxmClass << 16 | ericField << 9 | (hasMask ? 1 : 0) << 8 | length; + headerAsLong = (long) oxmClass << 16 | ericField << 9 | (hasMask ? 1 : 0) << 8 | length; } private static long extractSub(final long value, final int nrBits, final int offset) {