Package org.fest.util
Class Collections
- java.lang.Object
-
- org.fest.util.Collections
-
public final class Collections extends java.lang.Object
Utility methods related toCollection
s.- Author:
- Yvonne Wang, Alex Ruiz, Joel Costigliola
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.util.Collection<T>
duplicatesFrom(java.util.Collection<T> c)
Returns any duplicate elements from the givenCollection
.static java.lang.String
format(java.util.Collection<?> c)
Returns theString
representation of the givenCollection
, ornull
if the givenCollection
isnull
.static boolean
isNullOrEmpty(java.util.Collection<?> c)
Indicates whether the givenCollection
isnull
or empty.static <T> java.util.List<T>
nonNullElementsIn(java.util.Collection<T> c)
Returns all the non-null
elements in the givenCollection
.
-
-
-
Method Detail
-
duplicatesFrom
public static <T> java.util.Collection<T> duplicatesFrom(java.util.Collection<T> c)
Returns any duplicate elements from the givenCollection
.- Type Parameters:
T
- the generic type of the givenCollection
.- Parameters:
c
- the givenCollection
that might have duplicate elements.- Returns:
- a
Collection
containing the duplicate elements of the given one. If no duplicates are found, an emptyCollection
is returned.
-
isNullOrEmpty
public static boolean isNullOrEmpty(java.util.Collection<?> c)
Indicates whether the givenCollection
isnull
or empty.- Parameters:
c
- the givenCollection
.- Returns:
true
if the givenCollection
isnull
or empty, otherwisefalse
.
-
format
public static java.lang.String format(java.util.Collection<?> c)
Returns theString
representation of the givenCollection
, ornull
if the givenCollection
isnull
.- Parameters:
c
- theCollection
to format.- Returns:
- the
String
representation of the givenCollection
.
-
nonNullElementsIn
public static <T> java.util.List<T> nonNullElementsIn(java.util.Collection<T> c)
Returns all the non-null
elements in the givenCollection
.- Type Parameters:
T
- the type of elements of theCollection
.- Parameters:
c
- the givenCollection
.- Returns:
- all the non-
null
elements in the givenCollection
. An empty list is returned if the givenCollection
isnull
. - Since:
- 1.1.3
-
-