Package org.fest.util
Class Collections
- java.lang.Object
-
- org.fest.util.Collections
-
public final class Collections extends java.lang.ObjectUtility methods related toCollections.- 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.Stringformat(java.util.Collection<?> c)Returns theStringrepresentation of the givenCollection, ornullif the givenCollectionisnull.static booleanisNullOrEmpty(java.util.Collection<?> c)Indicates whether the givenCollectionisnullor empty.static <T> java.util.List<T>nonNullElementsIn(java.util.Collection<T> c)Returns all the non-nullelements 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 givenCollectionthat might have duplicate elements.- Returns:
- a
Collectioncontaining the duplicate elements of the given one. If no duplicates are found, an emptyCollectionis returned.
-
isNullOrEmpty
public static boolean isNullOrEmpty(java.util.Collection<?> c)
Indicates whether the givenCollectionisnullor empty.- Parameters:
c- the givenCollection.- Returns:
trueif the givenCollectionisnullor empty, otherwisefalse.
-
format
public static java.lang.String format(java.util.Collection<?> c)
Returns theStringrepresentation of the givenCollection, ornullif the givenCollectionisnull.- Parameters:
c- theCollectionto format.- Returns:
- the
Stringrepresentation of the givenCollection.
-
nonNullElementsIn
public static <T> java.util.List<T> nonNullElementsIn(java.util.Collection<T> c)
Returns all the non-nullelements in the givenCollection.- Type Parameters:
T- the type of elements of theCollection.- Parameters:
c- the givenCollection.- Returns:
- all the non-
nullelements in the givenCollection. An empty list is returned if the givenCollectionisnull. - Since:
- 1.1.3
-
-