Remove overloads of NonNullUtils#checkNotNull()
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Tue, 24 Nov 2015 23:51:18 +0000 (18:51 -0500)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Sun, 29 Nov 2015 03:56:21 +0000 (22:56 -0500)
New errors have cropped up with the latest integration build. It seems
JDT is now stricter with regards to annotated generic types vs.
un-annotated ones (where before un-annotated was similar to @Nullable,
now we don't we away with it that easily).

Variants of checkNotNull() method that used to help the compiler now
seem to do more harm than good. Just deferring to the basic "T" one
fixes the new errors. Perhaps this should have been the ideal approach
all along?

Change-Id: If998d5554b5d85ac785d21365dfeeae5d6a48bb8
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Reviewed-on: https://git.eclipse.org/r/60650
Reviewed-by: Hudson CI
common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/NonNullUtils.java
statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/treemap/TreeMapStore.java

index 119c3fac641c39965cb395ee93203ff0daffe47d..3a46d9aad0eae3530ebeb1f5a81a020f9a79a370 100644 (file)
@@ -13,7 +13,6 @@
 package org.eclipse.tracecompass.common.core;
 
 import java.util.Arrays;
-import java.util.Map;
 import java.util.stream.Stream;
 
 import org.eclipse.jdt.annotation.NonNull;
@@ -91,68 +90,6 @@ public final class NonNullUtils {
         return obj;
     }
 
-    /**
-     * Convert a non-annotated [] array reference to a @NonNull one.
-     *
-     * Note that this method does not check the array contents itself, which can
-     * still contain null elements.
-     *
-     * @param array
-     *            The array whose reference should not be null
-     * @return A {@link NonNull} reference to the array
-     * @throws NullPointerException
-     *             If the reference was actually null
-     * @since 2.0
-     */
-    public static <T> T[] checkNotNull(T @Nullable [] array) {
-        if (array == null) {
-            throw new NullPointerException();
-        }
-        return array;
-    }
-
-    /**
-     * Convert a non-annotated {@link Iterable} to a NonNull one.
-     *
-     * Note that, unlike {{@link #checkNotNull(Object)}}, this method does not
-     * check the contents itself, which can still contain null elements.
-     *
-     * @param container
-     *            The iterable whose reference should not be null
-     * @return A {@link NonNull} reference to the Iterable. The original class
-     *         type is preserved.
-     * @throws NullPointerException
-     *             If the reference was actually null
-     * @since 2.0
-     */
-    public static <T, C extends Iterable<T>> C checkNotNull(@Nullable C container) {
-        if (container == null) {
-            throw new NullPointerException();
-        }
-        return container;
-    }
-
-    /**
-     * Convert a non-annotated {@link Map} to a NonNull one.
-     *
-     * Note that, unlike {{@link #checkNotNull(Object)}}, this method does not
-     * check the keys or values themselves, which can still contain null
-     * elements.
-     *
-     * @param map
-     *            The map whose reference should not be null
-     * @return A {@link NonNull} reference to the Map
-     * @throws NullPointerException
-     *             If the reference was actually null
-     * @since 2.0
-     */
-    public static <K, V, M extends Map<K, V>> M checkNotNull(@Nullable M map) {
-        if (map == null) {
-            throw new NullPointerException();
-        }
-        return map;
-    }
-
     /**
      * Ensures a {@link Stream} does not contain any null values.
      *
index 0b3921ee147378669cf7d888563e69bd73710083..590f25057e0c074c1cfe722ccd5f7804372cd50a 100644 (file)
@@ -20,6 +20,7 @@ import java.util.TreeMap;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.segmentstore.core.ISegment;
 import org.eclipse.tracecompass.segmentstore.core.ISegmentStore;
@@ -52,7 +53,7 @@ import com.google.common.collect.TreeMultimap;
  *
  * @author Alexandre Montplaisir
  */
-public class TreeMapStore<E extends ISegment> implements ISegmentStore<E> {
+public class TreeMapStore<@NonNull E extends ISegment> implements ISegmentStore<E> {
 
     private final ReadWriteLock fLock = new ReentrantReadWriteLock(false);
 
This page took 0.027066 seconds and 5 git commands to generate.