at.molindo.utils.collections
Class CollectionUtils

java.lang.Object
  extended by at.molindo.utils.collections.CollectionUtils

public class CollectionUtils
extends Object


Method Summary
static
<C extends Collection<T>,T,F>
C
add(C to, F o, Function<? super F,T> f)
           
static
<C extends Collection<T>,T,F>
C
addAll(C to, Collection<? extends F> from, Function<? super F,T> f)
           
static boolean empty(Collection<?> c)
           
static boolean empty(Map<?,?> c)
           
static
<T,V> T
find(Collection<T> c, Function<T,Boolean> f)
           
static
<T,V> T
find(Collection<T> c, Function<T,V> f, V match)
           
static
<T,V> List<T>
findAll(Collection<T> c, Function<T,Boolean> f)
           
static
<T,V> List<T>
findAll(Collection<T> c, Function<T,V> f, V match)
           
static
<T> T
first(Iterable<T> c)
           
static
<K,V> Map.Entry<K,V>
first(Map<K,V> c)
           
static
<K> K
firstKey(Map<K,?> c)
           
static
<V> V
firstValue(Map<?,V> c)
           
static
<E> ArrayList<E>
list(E... e)
           
static
<E> ArrayList<E>
list(Iterable<E> e)
           
static
<M extends Map<T,F>,T,F>
M
put(M to, F o, Function<? super F,T> f)
           
static
<M extends Map<T,F>,T,F>
M
putAll(M to, Collection<? extends F> from, Function<? super F,T> f)
           
static
<K,V> V
putIfAbsent(ConcurrentMap<K,V> map, K key, V value)
           
static
<T> List<T>
resize(List<T> list, int size)
           
static
<T> List<T>
resize(List<T> list, int size, T defaultValue)
           
static
<T> List<T>
resize(List<T> list, int size, T defaultValue, Collection<T> obsolete)
           
static
<E> HashSet<E>
set(E... e)
           
static
<E> HashSet<E>
set(Iterable<E> e)
           
static
<T> List<T>
set(List<T> list, int idx, T obj)
          set index of list to obj, resizing list if necessary
static
<T> List<T>
set(List<T> list, int idx, T obj, T defaultValue)
           
static
<E> TreeSet<E>
sortedSet(E... e)
           
static
<E> TreeSet<E>
sortedSet(Iterable<E> e)
           
static
<T> List<T>
subList(List<T> list, int first, int count)
          a sublist implementation that is diffrent from List.subList(int, int) as it handles out of bounds indexes gracefully
static
<E> List<E>
unmodifiableList(E... e)
           
static
<E> List<E>
unmodifiableList(Iterable<E> e)
           
static
<E> Set<E>
unmodifiableSet(E... e)
           
static
<E> Set<E>
unmodifiableSet(Iterable<E> e)
           
static
<E> SortedSet<E>
unmodifiableSortedSet(E... e)
           
static
<E> SortedSet<E>
unmodifiableSortedSet(Iterable<E> e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

unmodifiableSet

public static <E> Set<E> unmodifiableSet(Iterable<E> e)

unmodifiableSet

public static <E> Set<E> unmodifiableSet(E... e)

set

public static <E> HashSet<E> set(E... e)

set

public static <E> HashSet<E> set(Iterable<E> e)

unmodifiableSortedSet

public static <E> SortedSet<E> unmodifiableSortedSet(E... e)

unmodifiableSortedSet

public static <E> SortedSet<E> unmodifiableSortedSet(Iterable<E> e)

sortedSet

public static <E> TreeSet<E> sortedSet(E... e)

sortedSet

public static <E> TreeSet<E> sortedSet(Iterable<E> e)

unmodifiableList

public static <E> List<E> unmodifiableList(E... e)

unmodifiableList

public static <E> List<E> unmodifiableList(Iterable<E> e)

list

public static <E> ArrayList<E> list(E... e)

list

public static <E> ArrayList<E> list(Iterable<E> e)

subList

public static <T> List<T> subList(List<T> list,
                                  int first,
                                  int count)
a sublist implementation that is diffrent from List.subList(int, int) as it handles out of bounds indexes gracefully


empty

public static boolean empty(Collection<?> c)

empty

public static boolean empty(Map<?,?> c)

first

public static <T> T first(Iterable<T> c)

first

public static <K,V> Map.Entry<K,V> first(Map<K,V> c)

firstKey

public static <K> K firstKey(Map<K,?> c)

firstValue

public static <V> V firstValue(Map<?,V> c)

putIfAbsent

public static <K,V> V putIfAbsent(ConcurrentMap<K,V> map,
                                  K key,
                                  V value)

find

public static <T,V> T find(Collection<T> c,
                           Function<T,Boolean> f)

findAll

public static <T,V> List<T> findAll(Collection<T> c,
                                    Function<T,Boolean> f)

find

public static <T,V> T find(Collection<T> c,
                           Function<T,V> f,
                           V match)

findAll

public static <T,V> List<T> findAll(Collection<T> c,
                                    Function<T,V> f,
                                    V match)

add

public static <C extends Collection<T>,T,F> C add(C to,
                                                  F o,
                                                  Function<? super F,T> f)

addAll

public static <C extends Collection<T>,T,F> C addAll(C to,
                                                     Collection<? extends F> from,
                                                     Function<? super F,T> f)

put

public static <M extends Map<T,F>,T,F> M put(M to,
                                             F o,
                                             Function<? super F,T> f)

putAll

public static <M extends Map<T,F>,T,F> M putAll(M to,
                                                Collection<? extends F> from,
                                                Function<? super F,T> f)

resize

public static <T> List<T> resize(List<T> list,
                                 int size)

resize

public static <T> List<T> resize(List<T> list,
                                 int size,
                                 T defaultValue)

resize

public static <T> List<T> resize(List<T> list,
                                 int size,
                                 T defaultValue,
                                 Collection<T> obsolete)

set

public static <T> List<T> set(List<T> list,
                              int idx,
                              T obj)
set index of list to obj, resizing list if necessary

Type Parameters:
T -
Parameters:
list -
idx -
obj -
Returns:

set

public static <T> List<T> set(List<T> list,
                              int idx,
                              T obj,
                              T defaultValue)


Copyright © 2013 Molindo GmbH. All Rights Reserved.