From 8b4dd0fc25ea0c0cb03f1520e68980b536fbb5d1 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Tue, 16 May 2023 16:39:58 +0200 Subject: [PATCH] Annotate CollectionUtils methods with @Nullable, @Nonnull --- .../java/org/pgpainless/util/CollectionUtils.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pgpainless-core/src/main/java/org/pgpainless/util/CollectionUtils.java b/pgpainless-core/src/main/java/org/pgpainless/util/CollectionUtils.java index e901eecc..8fcac2ce 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/util/CollectionUtils.java +++ b/pgpainless-core/src/main/java/org/pgpainless/util/CollectionUtils.java @@ -4,6 +4,7 @@ package org.pgpainless.util; +import javax.annotation.Nonnull; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Collection; @@ -23,7 +24,8 @@ public final class CollectionUtils { * @param type * @return list */ - public static List iteratorToList(Iterator iterator) { + @Nonnull + public static List iteratorToList(@Nonnull Iterator iterator) { List items = new ArrayList<>(); while (iterator.hasNext()) { I item = iterator.next(); @@ -39,7 +41,8 @@ public final class CollectionUtils { * @param type * @return t and ts as array */ - public static T[] concat(T t, T[] ts) { + @Nonnull + public static T[] concat(@Nonnull T t, @Nonnull T[] ts) { T[] concat = (T[]) Array.newInstance(t.getClass(), ts.length + 1); concat[0] = t; System.arraycopy(ts, 0, concat, 1, ts.length); @@ -53,7 +56,7 @@ public final class CollectionUtils { * @param type * @return true if ts contains t, false otherwise */ - public static boolean contains(T[] ts, T t) { + public static boolean contains(@Nonnull T[] ts, @Nonnull T t) { for (T i : ts) { if (i.equals(t)) { return true; @@ -69,7 +72,7 @@ public final class CollectionUtils { * @param iterator iterator to gather items from * @param collection collection to add items to */ - public static void addAll(Iterator iterator, Collection collection) { + public static void addAll(@Nonnull Iterator iterator, @Nonnull Collection collection) { while (iterator.hasNext()) { collection.add(iterator.next()); }