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 91b48ba2..e4414b31 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/util/CollectionUtils.java +++ b/pgpainless-core/src/main/java/org/pgpainless/util/CollectionUtils.java @@ -15,6 +15,13 @@ public final class CollectionUtils { } + /** + * Return all items returned by the {@link Iterator} as a {@link List}. + * + * @param iterator iterator + * @param type + * @return list + */ public static List iteratorToList(Iterator iterator) { List items = new ArrayList<>(); while (iterator.hasNext()) { @@ -24,6 +31,13 @@ public final class CollectionUtils { return items; } + /** + * Return a new array which contains
t
as first element, followed by the elements of
ts
. + * @param t head + * @param ts tail + * @param type + * @return t and ts as array + */ public static T[] concat(T t, T[] ts) { T[] concat = (T[]) Array.newInstance(t.getClass(), ts.length + 1); concat[0] = t; @@ -31,6 +45,13 @@ public final class CollectionUtils { return concat; } + /** + * Return true, if the given array
ts
contains the element
t
. + * @param ts elements + * @param t searched element + * @param type + * @return true if ts contains t, false otherwise + */ public static boolean contains(T[] ts, T t) { for (T i : ts) { if (i.equals(t)) {