|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jaitools.CollectionFactory
public class CollectionFactory
Convenience methods to create generic collections following the DRY (Don't Repeat Yourself) principle. Examples of use:
// simple
List<Integer> list1 = CollectionFactory.list();
// nested
List<List<String>> list2 = CollectionFactory.list();
// a multi-map
Map<String, List<Integer>> multiMap = CollectionFactory.map();
| Constructor Summary | |
|---|---|
CollectionFactory()
|
|
| Method Summary | ||
|---|---|---|
static
|
list()
Returns a new List object. |
|
static
|
map()
Returns a new Map object. |
|
static
|
orderedMap()
Returns a new Map object that maintains insertion
order. |
|
static
|
orderedSet()
Returns a new Set instance that maintains
the insertion order of its elements. |
|
static
|
set()
Returns a new Set instance. |
|
static
|
sortedMap()
Returns a new SortedMap object. |
|
static
|
sortedSet()
Returns a new SortedSet instance. |
|
static
|
stack()
Returns a new Stack object. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CollectionFactory()
| Method Detail |
|---|
public static <K,V> Map<K,V> map()
Map object. The returned
object is a HashMap.
Example of use:
Map<Foo, Bar> myMap = CollectionFactory.map();
K - key typeV - value type
public static <K,V> Map<K,V> orderedMap()
Map object that maintains insertion
order. The returned object is a LinkedHashMap.
Example of use:
Map<Foo, Bar> myMap = CollectionFactory.orderedMap();
K - key typeV - value type
public static <K,V> SortedMap<K,V> sortedMap()
SortedMap object. Key type K must
implement Comparable. The returned object is a
TreeMap.
Example of use:
Map<Foo, Bar> myMap = CollectionFactory.sortedMap();
K - key typeV - value type
public static <T> List<T> list()
List object. The returned object is
an ArrayList.
Example of use:
List<Foo> myList = CollectionFactory.list();
T - element type
public static <T> Stack<T> stack()
Stack object.
Example of use:
Stack<Foo> myStack = CollectionFactory.stack();
T - element type
public static <T> Set<T> set()
Set instance. The returned object is
a HashSet.
Example of use:
Set<Foo> mySet = CollectionFactory.set();
T - element type
public static <T> Set<T> orderedSet()
Set instance that maintains
the insertion order of its elements.
Example of use:
Set<Foo> mySet = CollectionFactory.set();
T - element type
public static <T> SortedSet<T> sortedSet()
SortedSet instance. The type T
must implement Comparable. The returned object
is a TreeSet.
Example of use:
Set<MyObject> foo = CollectionFactory.sortedSet();
T - element type
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||