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):
| Method from org.apache.tapestry5.ioc.internal.util.CollectionFactory Detail: |
public static Map<String, V> newCaseInsensitiveMap() {
return new CaseInsensitiveMap< V >();
}
|
public static Map<String, V> newCaseInsensitiveMap(Map<String, ? extends V> map) {
return new CaseInsensitiveMap< V >(map);
}
|
public static ConcurrentMap<K, V> newConcurrentMap() {
return new ConcurrentHashMap< K, V >();
}
Constructs a new concurrent map, which is safe to access via multiple threads. |
public static LinkedList<T> newLinkedList() {
return new LinkedList< T >();
}
|
public static List<T> newList() {
return new ArrayList< T >();
}
|
public static List<T> newList(V elements) {
// Was call to newList(), but Sun JDK can't handle that.
return new ArrayList< T >(Arrays.asList(elements));
}
Creates a new, fully modifiable list from an initial set of elements. |
public static List<T> newList(Collection<V> list) {
return new ArrayList< T >(list);
}
|
public static Map<K, V> newMap() {
return new HashMap< K, V >();
}
Constructs and returns a generic HashMap instance. |
public static Map<K, V> newMap(Map<? extends K, ? extends V> map) {
return new HashMap< K, V >(map);
}
|
public static Set<T> newSet() {
return new HashSet< T >();
}
|
public static Set<T> newSet(Collection<V> values) {
return new HashSet< T >(values);
}
Contructs a new HashSet and initializes it using the provided collection. |
public static Set<T> newSet(V values) {
// Was a call to newSet(), but Sun JDK can't handle that. Fucking generics.
return new HashSet< T >(Arrays.asList(values));
}
|
public static Stack<T> newStack() {
return new Stack< T >();
}
|
public static Stack<T> newStack(int initialSize) {
return new Stack< T >(initialSize);
}
|
public static List<T> newThreadSafeList() {
return new CopyOnWriteArrayList< T >();
}
|