Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tapestry5.ioc.internal.util
Class CollectionFactory

    java.lang.Object
      org.apache.tapestry5.ioc.internal.util.CollectionFactory

    public final class CollectionFactory

extends java.lang.Object

Static factory methods to ease the creation of new collection types (when using generics). Most of these method leverage the compiler's ability to match generic types by return value. Typical usage (with a static import):

     Map<Foo, Bar> map = newMap();

This is a replacement for:

     Map<Foo, Bar> map = new HashMap<Foo, Bar>();

Constructor Summary
`CollectionFactory()`

Method Summary
`static
`<V> java.util.Map<java.lang.String,V>`
` | `newCaseInsensitiveMap()`
`static
`<V> java.util.Map<java.lang.String,V>`
` | `newCaseInsensitiveMap(java.util.Map<java.lang.String,? extends V> map)`
`static
`<K,V> java.util.concurrent.ConcurrentMap<K,V>`
` | `newConcurrentMap()` Constructs a new concurrent map, which is safe to access via multiple threads.
`static
`<T> java.util.LinkedList<T>`
` | `newLinkedList()` Useful for queues.
`static
`<T> java.util.List<T>`
` | `newList()` Contructs and returns a new generic `ArrayList` instance.
`static
`<T,V extends T> java.util.List<T>`
` | `newList(java.util.Collection<V> list)` Constructs and returns a new `ArrayList` as a copy of the provided collection.
`static
`<T,V extends T> java.util.List<T>`
` | `newList(V... elements)` Creates a new, fully modifiable list from an initial set of elements.
`static
`<K,V> java.util.Map<K,V>`
` | `newMap()` Constructs and returns a generic `HashMap` instance.
`static
`<K,V> java.util.Map<K,V>`
` | `newMap(java.util.Map<? extends K,? extends V> map)` Constructs a new `HashMap` instance by copying an existing Map instance.
`static
`<T> java.util.Set<T>`
` | `newSet()` Constructs and returns a generic `HashSet` instance.
`static
`<T,V extends T> java.util.Set<T>`
` | `newSet(java.util.Collection<V> values)` Contructs a new `HashSet` and initializes it using the provided collection.
`static
`<T,V extends T> java.util.Set<T>`
` | `newSet(V... values)`
`static
`<T> Stack<T>`
` | `newStack()`
`static
`<T> Stack<T>`
` | `newStack(int initialSize)`
`static
`<T> java.util.List<T>`
` | `newThreadSafeList()` Constructs and returns a new `CopyOnWriteArrayList`.
`static
`<K,V> java.util.Map<K,V>`
` | `newWeakHashMap()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### CollectionFactory

    public CollectionFactory()

Method Detail

### newMap

    public static <K,V> java.util.Map<K,V> newMap()

  Constructs and returns a generic `HashMap` instance.

### newSet

    public static <T> java.util.Set<T> newSet()

  Constructs and returns a generic `HashSet` instance.

### newSet

    public static <T,V extends T> java.util.Set<T> newSet(java.util.Collection<V> values)

  Contructs a new `HashSet` and initializes it using the provided collection.

### newSet

    public static <T,V extends T> java.util.Set<T> newSet(V... values)

### newMap

    public static <K,V> java.util.Map<K,V> newMap(java.util.Map<? extends K,? extends V> map)

  Constructs a new `HashMap` instance by copying an existing Map instance.

### newConcurrentMap

    public static <K,V> java.util.concurrent.ConcurrentMap<K,V> newConcurrentMap()

  Constructs a new concurrent map, which is safe to access via multiple threads.

### newWeakHashMap

    public static <K,V> java.util.Map<K,V> newWeakHashMap()

  Since:
    5.3

### newList

    public static <T> java.util.List<T> newList()

  Contructs and returns a new generic `ArrayList` instance.

### newList

    public static <T,V extends T> java.util.List<T> newList(V... elements)

  Creates a new, fully modifiable list from an initial set of elements.

### newLinkedList

    public static <T> java.util.LinkedList<T> newLinkedList()

  Useful for queues.

### newList

    public static <T,V extends T> java.util.List<T> newList(java.util.Collection<V> list)

  Constructs and returns a new `ArrayList` as a copy of the provided collection.

### newThreadSafeList

    public static <T> java.util.List<T> newThreadSafeList()

  Constructs and returns a new `CopyOnWriteArrayList`.

### newStack

    public static <T> Stack<T> newStack()

### newStack

    public static <T> Stack<T> newStack(int initialSize)

### newCaseInsensitiveMap

    public static <V> java.util.Map<java.lang.String,V> newCaseInsensitiveMap()

### newCaseInsensitiveMap

    public static <V> java.util.Map<java.lang.String,V> newCaseInsensitiveMap(java.util.Map<java.lang.String,? extends V> map)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2012 The Apache Software Foundation.