Package org.fest.util
Class Collections
java.lang.Object
org.fest.util.Collections
Utility methods related to
Collection
s.- Author:
- Yvonne Wang, Alex Ruiz, Joel Costigliola
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Collection<T>
duplicatesFrom
(Collection<T> c) Returns any duplicate elements from the givenCollection
.static String
format
(Collection<?> c) Returns theString
representation of the givenCollection
, ornull
if the givenCollection
isnull
.static boolean
isNullOrEmpty
(Collection<?> c) Indicates whether the givenCollection
isnull
or empty.static <T> List<T>
nonNullElementsIn
(Collection<T> c) Returns all the non-null
elements in the givenCollection
.
-
Method Details
-
duplicatesFrom
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
Indicates whether the givenCollection
isnull
or empty.- Parameters:
c
- the givenCollection
.- Returns:
true
if the givenCollection
isnull
or empty, otherwisefalse
.
-
format
Returns theString
representation of the givenCollection
, ornull
if the givenCollection
isnull
.- Parameters:
c
- theCollection
to format.- Returns:
- the
String
representation of the givenCollection
.
-
nonNullElementsIn
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
-