public final class Collections extends Object
Modifier and Type | Method and Description |
---|---|
static <T> Collection<T> |
duplicatesFrom(Collection<T> c)
Returns any duplicate elements from the given collection.
|
static <T> List<T> |
filter(Collection<?> target,
CollectionFilter<T> filter) |
static String |
format(Collection<?> c)
Returns the
String representation of the given collection, or null if the given collection is
null . |
static boolean |
hasOnlyNullElements(Iterable<?> iterable)
|
static boolean |
isEmpty(Iterable<?> iterable)
|
static <T> List<T> |
list(Iterable<T> iterable)
Creates a list containing the given
Iterable elements. |
static <T> List<T> |
list(T... elements)
Creates a list containing the given elements.
|
static <T> Collection<T> |
nonNullElements(Collection<T> c)
Returns a new unmodifiable collection containing the non-null elements of the given collection.
|
static <T> List<T> |
nonNullElements(List<T> l)
Returns a new unmodifiable list containing the non-null elements of the given list.
|
static <T> Set<T> |
set(T... elements)
Creates a set containing the given elements.
|
static int |
sizeOf(Iterable<?> iterable)
Returns the size of the given
Iterable . |
public static <T> List<T> list(T... elements)
T
- the type of elements of the list to create.elements
- the elements to store in the list.public static <T> Set<T> set(T... elements)
T
- the type of elements of the set to create.elements
- the elements to store in the set.public static <T> Collection<T> duplicatesFrom(Collection<T> c)
T
- the generic type of the given collection.c
- the given collection that might have duplicate elements.public static boolean isEmpty(Iterable<?> iterable)
public static int sizeOf(Iterable<?> iterable)
Iterable
.iterable
- the Iterable
to get size.Iterable
..IllegalArgumentException
- if given Iterable
is null.public static <T> List<T> filter(Collection<?> target, CollectionFilter<T> filter)
public static String format(Collection<?> c)
String
representation of the given collection, or null
if the given collection is
null
.c
- the collection to format.String
representation of the given collection.public static <T> Collection<T> nonNullElements(Collection<T> c)
null
elements or if it is empty. This
method returns null
if the given collection is null
.T
- the type of elements of the collection.c
- the collection we want to extract non null elements from.null
if
the given collection is null
.public static <T> List<T> nonNullElements(List<T> l)
null
elements or if it is empty. This method returns
null
if the given list is null
.T
- the type of elements of the list.l
- the list we want to extract non null elements from.null
if the given
list is null
.public static boolean hasOnlyNullElements(Iterable<?> iterable)
true
if the given Iterable
has only null
elements, false
otherwise. If given
Iterable
is empty, this method returns true
.iterable
- the given iterable. It must not be null.true
if the given iterable has only null
elements or is empty, false
otherwise.NullPointerException
- if the given iterable is null
.Copyright © 2007-2012 FEST (Fixtures for Easy Software Testing). All Rights Reserved.