Package org.pgpainless.util

# Class CollectionUtils

java.lang.Object
org.pgpainless.util.CollectionUtils

public final class CollectionUtils extends Object

## Method Summary

Modifier and Type
Method
Description
`static <T> void`
`addAll(Iterator<T> iterator, Collection<T> collection)`
Add all items from the iterator to the collection.
`static <T> T[]`
`concat(T t, T[] ts)`
Return a new array which contains
`static <T> boolean`
`contains(T[] ts, T t)`
Return true, if the given array
`static <I> List<I>`
`iteratorToList(Iterator<I> iterator)`
Return all items returned by the `Iterator` as a `List`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### iteratorToList

@Nonnull public static <I> List<I> iteratorToList(@Nonnull Iterator<I> iterator)
Return all items returned by the `Iterator` as a `List`.

Type Parameters:
  `I` - type
Parameters:
  `iterator` - iterator
Returns:
  list

### concat

@Nonnull public static <T> T[] concat(@Nonnull T t, @Nonnull T[] ts)
Return a new array which contains

    t

as first element, followed by the elements of

    ts

.

Type Parameters:
  `T` - type
Parameters:
  `t` - head
  `ts` - tail
Returns:
  t and ts as array

### contains

public static <T> boolean contains(@Nonnull T[] ts, @Nonnull T t)
Return true, if the given array

    ts

contains the element

    t

.

Type Parameters:
  `T` - type
Parameters:
  `ts` - elements
  `t` - searched element
Returns:
  true if ts contains t, false otherwise

### addAll

public static <T> void addAll(@Nonnull Iterator<T> iterator, @Nonnull Collection<T> collection)
Add all items from the iterator to the collection.

Type Parameters:
  `T` - type of item
Parameters:
  `iterator` - iterator to gather items from
  `collection` - collection to add items to