org.assertj.core.util
Class Collections

java.lang.Object
  extended by org.assertj.core.util.Collections

public final class Collections
extends Object

Utility methods related to Collections.

Author:
Yvonne Wang, Alex Ruiz, Joel Costigliola

Method Summary
static
<T> Collection<T>
duplicatesFrom(Collection<T> c)
          Returns any duplicate elements from the given Collection.
static String format(Collection<?> c)
          Returns the String standard representation of the given Collection, or null if the given Collection is null.
static String format(Collection<?> c, String start, String end)
          Returns the String standard representation of the given Collection, or null if the given Collection is null.
static String format(Representation p, Collection<?> c)
          Returns the String representation of the given Collection, or null if the given Collection is null.
static String format(Representation p, Collection<?> c, String start, String end)
          Returns the String representation of the given Collection, or null if the given Collection is null.
static boolean isNullOrEmpty(Collection<?> c)
          Indicates whether the given Collection is null or empty.
static
<T> List<T>
nonNullElementsIn(Collection<T> c)
          Returns all the non-null elements in the given Collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

duplicatesFrom

public static <T> Collection<T> duplicatesFrom(Collection<T> c)
Returns any duplicate elements from the given Collection.

Type Parameters:
T - the generic type of the given Collection.
Parameters:
c - the given Collection that might have duplicate elements.
Returns:
a Collection containing the duplicate elements of the given one. If no duplicates are found, an empty Collection is returned.

isNullOrEmpty

public static boolean isNullOrEmpty(Collection<?> c)
Indicates whether the given Collection is null or empty.

Parameters:
c - the given Collection.
Returns:
true if the given Collection is null or empty, otherwise false.

format

public static String format(Collection<?> c)
Returns the String standard representation of the given Collection, or null if the given Collection is null.

Parameters:
c - the Collection to format.
Returns:
the String representation of the given Collection.

format

public static String format(Representation p,
                            Collection<?> c)
Returns the String representation of the given Collection, or null if the given Collection is null.

Parameters:
p -
c - the Collection to format.
Returns:
the String representation of the given Collection.

format

public static String format(Collection<?> c,
                            String start,
                            String end)
Returns the String standard representation of the given Collection, or null if the given Collection is null.

Parameters:
c - the Collection to format.
Returns:
the String representation of the given Collection.

format

public static String format(Representation p,
                            Collection<?> c,
                            String start,
                            String end)
Returns the String representation of the given Collection, or null if the given Collection is null.

Parameters:
p -
c - the Collection to format.
Returns:
the String representation of the given Collection.

nonNullElementsIn

public static <T> List<T> nonNullElementsIn(Collection<T> c)
Returns all the non-null elements in the given Collection.

Type Parameters:
T - the type of elements of the Collection.
Parameters:
c - the given Collection.
Returns:
all the non-null elements in the given Collection. An empty list is returned if the given Collection is null.
Since:
1.1.3


Copyright © 2013–2015 AssertJ. All rights reserved.