org.codeartisans.java.toolbox
Class Collections

java.lang.Object
  extended by org.codeartisans.java.toolbox.Collections

public final class Collections
extends java.lang.Object


Method Summary
static
<T> java.util.Collection<T>
added(java.util.Collection<T> left, java.util.Collection<T> right)
           
static boolean collectionEquals(java.util.Collection<?> oldCollection, java.util.Collection<?> newCollection)
           
static
<T> java.util.Collection<T>
filter(java.util.Collection<T> list, Filter<T>... filters)
          Filter a Collection using Filters and return a new Collection.
static
<T> java.lang.Iterable<T>
filter(java.lang.Iterable<T> list, Filter<T>... filters)
          Filter an Iterable using Filters and return a new Iterable.
static
<T> java.util.List<T>
filter(java.util.List<T> list, Filter<T>... filters)
          Filter a List using Filters and return a new List.
static
<T> T
firstElementOrNull(java.lang.Iterable<T> iterable)
           
static boolean isEmpty(java.lang.Iterable<?> iterable)
           
static
<T> java.util.Collection<T>
removed(java.util.Collection<T> left, java.util.Collection<T> right)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isEmpty

public static boolean isEmpty(java.lang.Iterable<?> iterable)
Returns:
TRUE if the Iterable is null or empty, otherwise return FALSE

firstElementOrNull

public static <T> T firstElementOrNull(java.lang.Iterable<T> iterable)
Returns:
The first element of the Iterable or null if it is null or empty.

filter

public static <T> java.util.List<T> filter(java.util.List<T> list,
                                           Filter<T>... filters)
Filter a List using Filters and return a new List. Filters are applied in given order on each element from source collection.
The returned collection contain all the source elements accepted by at least one Filter.


filter

public static <T> java.util.Collection<T> filter(java.util.Collection<T> list,
                                                 Filter<T>... filters)
Filter a Collection using Filters and return a new Collection. Filters are applied in given order on each element from source collection.
The returned collection contain all the source elements accepted by at least one Filter.


filter

public static <T> java.lang.Iterable<T> filter(java.lang.Iterable<T> list,
                                               Filter<T>... filters)
Filter an Iterable using Filters and return a new Iterable. Filters are applied in given order on each element from source collection.
The returned collection contain all the source elements accepted by at least one Filter.


collectionEquals

public static boolean collectionEquals(java.util.Collection<?> oldCollection,
                                       java.util.Collection<?> newCollection)
Parameters:
oldCollection - A Collection
newCollection - Another Collection
Returns:
True iff both collection are null or contains the same elements, false otherwise.

removed

public static <T> java.util.Collection<T> removed(java.util.Collection<T> left,
                                                  java.util.Collection<T> right)
Type Parameters:
T - Type of collection elements.
Parameters:
left - Left collection of query. Treated as an empty collection if null.
right - Right collection of query. Treated as an empty collection if null.
Returns:
A collection containing elements from the left collection not present in the right collection.

added

public static <T> java.util.Collection<T> added(java.util.Collection<T> left,
                                                java.util.Collection<T> right)
Type Parameters:
T - Type of collection elements.
Parameters:
left - Left collection of query. Treated as an empty collection if null.
right - Right collection of query. Treated as an empty collection if null.
Returns:
A collection containing elements from the right collection not present in the left collection.


Copyright © 2012. All Rights Reserved.