org.avis.util
Class Collections

java.lang.Object
  extended by org.avis.util.Collections

public final class Collections
extends Object

General collection utilities.

Author:
Matthew Phillips

Method Summary
static
<T> Set<T>
difference(Set<T> set1, Set<T> set2)
          Compute the difference between set1 and set2.
static void join(StringBuilder str, Iterable<?> items, char separator)
          Join a collection of items with a separator and append to a string builder.
static
<E> List<E>
list(E... items)
          Create an immutable list from a number of items.
static
<E> Map<E,E>
map(E... pairs)
          Create an immutable map from a number of item pairs: even items are keys, their adjacent items are values.
static
<E> Set<E>
set(E... items)
          Create an immutable set from a number of items.
static
<K,V> Map<K,V>
union(Map<K,V> map1, Map<K,V> map2)
          Compute the union of map1 and map2.
static
<T> Set<T>
union(Set<T> set1, Set<T> set2)
          Compute the union of set1 and set2.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

set

public static <E> Set<E> set(E... items)
Create an immutable set from a number of items.


list

public static <E> List<E> list(E... items)
Create an immutable list from a number of items.


map

public static <E> Map<E,E> map(E... pairs)
Create an immutable map from a number of item pairs: even items are keys, their adjacent items are values.


join

public static void join(StringBuilder str,
                        Iterable<?> items,
                        char separator)
Join a collection of items with a separator and append to a string builder.


difference

public static <T> Set<T> difference(Set<T> set1,
                                    Set<T> set2)
Compute the difference between set1 and set2. This is not guaranteed to generate a new set instance.


union

public static <T> Set<T> union(Set<T> set1,
                               Set<T> set2)
Compute the union of set1 and set2. This is not guaranteed to generate a new set instance: it will return set1 or set2 directly if the other set is empty.


union

public static <K,V> Map<K,V> union(Map<K,V> map1,
                                   Map<K,V> map2)
Compute the union of map1 and map2. This is not guaranteed to generate a new map instance: it will return map1 or map2 directly if the other map is empty. If there is a key/value overlap, map2 wins.



Copyright © 2008 Matthew Phillips. All Rights Reserved.