X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=binding%2Fyang-binding%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fbinding%2FCodeHelpers.java;fp=binding%2Fyang-binding%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fbinding%2FCodeHelpers.java;h=1a1870efc44bbe69f0a2bcbd08b98c76bdefba2f;hb=99dd61f2037307d1b59f72a47e89d845f138acde;hp=a62a586c690ba419c3713d6fdb0684788e5def77;hpb=e60ce63d3a25e6138fd04297ac370109ac8d4909;p=mdsal.git diff --git a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/CodeHelpers.java b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/CodeHelpers.java index a62a586c69..1a1870efc4 100644 --- a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/CodeHelpers.java +++ b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/CodeHelpers.java @@ -15,9 +15,7 @@ import com.google.common.base.MoreObjects.ToStringHelper; import com.google.common.base.VerifyException; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Arrays; -import java.util.Collection; import java.util.HexFormat; import java.util.List; import java.util.Map; @@ -32,8 +30,6 @@ import org.eclipse.jdt.annotation.Nullable; * Helper methods for generated binding code. This class concentrates useful primitives generated code may call * to perform specific shared functions. This allows for generated classes to be leaner. Methods in this class follows * general API stability requirements of the Binding Specification. - * - * @author Robert Varga */ public final class CodeHelpers { private CodeHelpers() { @@ -460,7 +456,7 @@ public final class CodeHelpers { @SuppressWarnings("unchecked") public static @Nullable List checkListFieldCast(final @NonNull Class requiredClass, final @NonNull String fieldName, final @Nullable List list) { - checkCollectionField(requiredClass, fieldName, list); + DoNotLeakSpotbugs.checkCollectionField(requiredClass, fieldName, list); return (List) list; } @@ -477,21 +473,7 @@ public final class CodeHelpers { @SuppressWarnings("unchecked") public static @Nullable Set checkSetFieldCast(final @NonNull Class requiredClass, final @NonNull String fieldName, final @Nullable Set set) { - checkCollectionField(requiredClass, fieldName, set); + DoNotLeakSpotbugs.checkCollectionField(requiredClass, fieldName, set); return (Set) set; } - - @SuppressFBWarnings(value = "DCN_NULLPOINTER_EXCEPTION", - justification = "Internal NPE->IAE conversion") - private static void checkCollectionField(final @NonNull Class requiredClass, - final @NonNull String fieldName, final @Nullable Collection collection) { - if (collection != null) { - try { - collection.forEach(item -> requiredClass.cast(requireNonNull(item))); - } catch (ClassCastException | NullPointerException e) { - throw new IllegalArgumentException("Invalid input item for property \"" + requireNonNull(fieldName) - + "\"", e); - } - } - } }