Class CollectionFactory
java.lang.Object
org.apache.tapestry5.commons.util.CollectionFactory
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> ConcurrentMap<K, V> Constructs a new concurrent map, which is safe to access via multiple threads.static <T> LinkedList<T>
Useful for queues.static <T> List<T>
newList()
Contructs and returns a new genericArrayList
instance.static <T,
V extends T>
List<T>newList
(Collection<V> list) Constructs and returns a newArrayList
as a copy of the provided collection.static <T,
V extends T>
List<T>newList
(V... elements) Creates a new, fully modifiable list from an initial set of elements.static <K,
V> Map<K, V> newMap()
Constructs and returns a genericHashMap
instance.static <K,
V> Map<K, V> Constructs a newHashMap
instance by copying an existing Map instance.static <T> Set<T>
newSet()
Constructs and returns a genericHashSet
instance.static <T,
V extends T>
Set<T>newSet
(Collection<V> values) Contructs a newHashSet
and initializes it using the provided collection.static <T,
V extends T>
Set<T>newSet
(V... values) static <T> Stack<T>
newStack()
static <T> List<T>
Constructs and returns a newCopyOnWriteArrayList
.
-
Constructor Details
-
CollectionFactory
public CollectionFactory()
-
-
Method Details
-
newMap
Constructs and returns a genericHashMap
instance. -
newSet
Constructs and returns a genericHashSet
instance. -
newSet
Contructs a newHashSet
and initializes it using the provided collection. -
newSet
-
newMap
Constructs a newHashMap
instance by copying an existing Map instance. -
newConcurrentMap
Constructs a new concurrent map, which is safe to access via multiple threads. -
newList
Contructs and returns a new genericArrayList
instance. -
newList
Creates a new, fully modifiable list from an initial set of elements. -
newLinkedList
Useful for queues. -
newList
Constructs and returns a newArrayList
as a copy of the provided collection. -
newThreadSafeList
Constructs and returns a newCopyOnWriteArrayList
. -
newStack
-
newCaseInsensitiveMap
-