ix.util
Class Collect

java.lang.Object
  |
  +--ix.util.Collect

public final class Collect
extends java.lang.Object

Collection and Map utilities

See Also:
Fn, Strings, Util

Method Summary
static java.util.List ensureList(java.util.List list)
          Ensures that a value is a List object by returning an empty list if the value is null.
static java.util.Collection filter(java.lang.Class resultClass, java.util.Collection c, Predicate1 p)
          Returns a new collection of the specified result class and and containing only the elements for which the predicate returned true;
static java.util.Collection filter(java.util.Collection c, Predicate1 p)
          Returns a new collection of the same class as the original and containing only the elements for which the predicate returned true;
static boolean isEmpty(java.util.Collection c)
          Returns true iff the collection is either null or empty.
static boolean isEmpty(java.util.Map m)
          Returns true iff the Map is either null or empty.
static java.util.Iterator iterator(java.util.Collection c)
          Returns the collections's iterator, treating null as an empty list.
static java.util.Collection map(java.lang.Class resultClass, java.util.Collection c, Function1 f)
          Returns a new collection of the specified result class and with elements obtained by calling the specified function on the corresponding elements of the original collection.
static java.util.Collection map(java.util.Collection c, Function1 f)
          Returns a new collection of the same class as the original and with corresponding elements obtained by calling the specified function.
static java.util.List replaceFirst(java.lang.Object from, java.lang.Object to, java.util.List source)
          Replaces the first occurrence of an item in a list, returning the modified list.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isEmpty

public static final boolean isEmpty(java.util.Collection c)
Returns true iff the collection is either null or empty.

isEmpty

public static final boolean isEmpty(java.util.Map m)
Returns true iff the Map is either null or empty.

iterator

public static final java.util.Iterator iterator(java.util.Collection c)
Returns the collections's iterator, treating null as an empty list.

ensureList

public static java.util.List ensureList(java.util.List list)
Ensures that a value is a List object by returning an empty list if the value is null.

replaceFirst

public static java.util.List replaceFirst(java.lang.Object from,
                                          java.lang.Object to,
                                          java.util.List source)
Replaces the first occurrence of an item in a list, returning the modified list. If the item does not occur, the list is returned unchanged.

map

public static java.util.Collection map(java.util.Collection c,
                                       Function1 f)
Returns a new collection of the same class as the original and with corresponding elements obtained by calling the specified function.

map

public static java.util.Collection map(java.lang.Class resultClass,
                                       java.util.Collection c,
                                       Function1 f)
Returns a new collection of the specified result class and with elements obtained by calling the specified function on the corresponding elements of the original collection.

filter

public static java.util.Collection filter(java.util.Collection c,
                                          Predicate1 p)
Returns a new collection of the same class as the original and containing only the elements for which the predicate returned true;

filter

public static java.util.Collection filter(java.lang.Class resultClass,
                                          java.util.Collection c,
                                          Predicate1 p)
Returns a new collection of the specified result class and and containing only the elements for which the predicate returned true;