@Test public void testRequireNonNullElements() { Collection<Integer> col = Objects.requireNonNullElements(Arrays.asList(1, 2, 3, 4)); assertThat(col, contains(1, 2, 3, 4)); }
@NotNull @Contract("null -> fail; !null -> param1") public static <T> Collection<T> requireNonNullElements(@NotNull Collection<T> collection) { requireNonNull(collection); for (T t : collection) { requireNonNull(t); } return collection; }
Objects { @NotNull @Contract("null -> fail; !null -> param1") public static <T> Collection<T> requireNonNullElements(@NotNull Collection<T> collection) { requireNonNull(collection); for (T t : collection) { requireNonNull(t); } return collection; } }
Objects { @NotNull @Contract("null -> fail; !null -> param1") public static <T> Collection<T> requireNonNullElements(@NotNull Collection<T> collection) { requireNonNull(collection); for (T t : collection) { requireNonNull(t); } return collection; } private  Objects(); }
Objects { @NotNull @Contract("null -> fail; !null -> param1") public static <T> Collection<T> requireNonNullElements(@NotNull Collection<T> collection) { requireNonNull(collection); for (T t : collection) { requireNonNull(t); } return collection; } private  Objects(); @Contract(pure = true) static boolean equals(@Nullable Object a, @Nullable Object b); @Contract(pure = true) static boolean deepEquals(@Nullable Object a, @Nullable Object b); @Contract(pure = true) static int hashCode(@Nullable Object o); @Contract(pure = true) static int hash(@Nullable Object... values); @NotNull @Contract("null, _ -> param2") static String toString(@Nullable Object o, @NotNull String nullDefault); @Contract(pure = true) static int compare(@Nullable T a, @Nullable T b, @NotNull Comparator<? super T> c); @Contract(pure = true) static int compareInt(int x, int y); @Contract(pure = true) static int compareLong(long x, long y); @NotNull @Contract(value = "null -> fail; !null -> param1", pure = true) static T requireNonNull(@Nullable T obj); @NotNull @Contract(value = "null, _ -> fail; !null, _ -> param1", pure = true) static T requireNonNull(@Nullable T obj, @NotNull String message); @NotNull @Contract("null, _ -> fail; !null, _ -> param1") static T requireNonNull(@Nullable T obj, @NotNull Supplier<String> messageSupplier); @NotNull @Contract(value = "!null, _ -> param1; null, !null -> param2; null, null -> fail", pure = true) static T requireNonNullElse(@Nullable T obj, @NotNull T defaultObj); @NotNull @Contract("!null, _ -> param1; null, null -> fail") static T requireNonNullElseGet(@Nullable T obj, @NotNull Supplier<? extends T> supplier); @NotNull @Contract("null -> fail; !null -> param1") static Collection<T> requireNonNullElements(@NotNull Collection<T> collection); @Contract(value = "null -> true; !null -> false", pure = true) static boolean isNull(@Nullable Object obj); @Contract(value = "null -> false; !null -> true", pure = true) static boolean nonNull(@Nullable Object obj); }
Objects { @NotNull @Contract("null -> fail; !null -> param1") public static <T> Collection<T> requireNonNullElements(@NotNull Collection<T> collection) { requireNonNull(collection); for (T t : collection) { requireNonNull(t); } return collection; } private  Objects(); @Contract(pure = true) static boolean equals(@Nullable Object a, @Nullable Object b); @Contract(pure = true) static boolean deepEquals(@Nullable Object a, @Nullable Object b); @Contract(pure = true) static int hashCode(@Nullable Object o); @Contract(pure = true) static int hash(@Nullable Object... values); @NotNull @Contract("null, _ -> param2") static String toString(@Nullable Object o, @NotNull String nullDefault); @Contract(pure = true) static int compare(@Nullable T a, @Nullable T b, @NotNull Comparator<? super T> c); @Contract(pure = true) static int compareInt(int x, int y); @Contract(pure = true) static int compareLong(long x, long y); @NotNull @Contract(value = "null -> fail; !null -> param1", pure = true) static T requireNonNull(@Nullable T obj); @NotNull @Contract(value = "null, _ -> fail; !null, _ -> param1", pure = true) static T requireNonNull(@Nullable T obj, @NotNull String message); @NotNull @Contract("null, _ -> fail; !null, _ -> param1") static T requireNonNull(@Nullable T obj, @NotNull Supplier<String> messageSupplier); @NotNull @Contract(value = "!null, _ -> param1; null, !null -> param2; null, null -> fail", pure = true) static T requireNonNullElse(@Nullable T obj, @NotNull T defaultObj); @NotNull @Contract("!null, _ -> param1; null, null -> fail") static T requireNonNullElseGet(@Nullable T obj, @NotNull Supplier<? extends T> supplier); @NotNull @Contract("null -> fail; !null -> param1") static Collection<T> requireNonNullElements(@NotNull Collection<T> collection); @Contract(value = "null -> true; !null -> false", pure = true) static boolean isNull(@Nullable Object obj); @Contract(value = "null -> false; !null -> true", pure = true) static boolean nonNull(@Nullable Object obj);  }