Package org.python.util
Class Generic
- java.lang.Object
-
- org.python.util.Generic
-
public class Generic extends java.lang.Object
Static methods to make instances of collections with their generic types inferred from what they're being assigned to. The idea is stolen fromSets
,Lists
andMaps
from Google Collections.
-
-
Field Summary
Fields Modifier and Type Field Description static int
CHM_CONCURRENCY_LEVEL
static int
CHM_INITIAL_CAPACITY
Our default ConcurrentHashMap sizes.static float
CHM_LOAD_FACTOR
-
Constructor Summary
Constructors Constructor Description Generic()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <K,V>
java.util.concurrent.ConcurrentMap<K,V>concurrentMap()
Makes a ConcurrentMap using generic types inferred from whatever this is being assigned to.static <E> java.util.Set<E>
concurrentSet()
Makes a Set, ensuring safe concurrent operations, using generic types inferred from whatever this is being assigned to.static <K,V>
java.util.Map<K,V>identityHashMap()
Makes an IdentityHashMap using generic types inferred from whatever this is being assigned to.static <K,V>
java.util.Map<K,V>identityHashMap(int capacity)
Makes an IdentityHashMap using generic types inferred from whatever this is being assigned to.static <E> java.util.Set<E>
linkedHashSet()
Makes a LinkedHashSet using the generic type inferred from whatever this is being assigned to.static <E> java.util.Set<E>
linkedHashSet(int capacity)
Makes a LinkedHashSet using the generic type inferred from whatever this is being assigned to.static <T> java.util.List<T>
list()
Makes a List with its generic type inferred from whatever it's being assigned to.static <T> java.util.List<T>
list(int capacity)
Makes a List with its generic type inferred from whatever it's being assigned to.static <T,U extends T>
java.util.List<T>list(U... contents)
Makes a List with its generic type inferred from whatever it's being assigned to filled with the items incontents
.static <K,V>
java.util.Map<K,V>map()
Makes a Map using generic types inferred from whatever this is being assigned to.static <E> java.util.Set<E>
set()
Makes a Set using the generic type inferred from whatever this is being assigned to.static <T,U extends T>
java.util.Set<T>set(U... contents)
Makes a Set using the generic type inferred from whatever this is being assigned to filled with the items incontents
.
-
-
-
Field Detail
-
CHM_INITIAL_CAPACITY
public static final int CHM_INITIAL_CAPACITY
Our default ConcurrentHashMap sizes. Only concurreny level differs from ConcurrentHashMap's defaults: it's significantly lower to reduce allocation cost.- See Also:
- Constant Field Values
-
CHM_LOAD_FACTOR
public static final float CHM_LOAD_FACTOR
- See Also:
- Constant Field Values
-
CHM_CONCURRENCY_LEVEL
public static final int CHM_CONCURRENCY_LEVEL
- See Also:
- Constant Field Values
-
-
Method Detail
-
list
public static <T> java.util.List<T> list()
Makes a List with its generic type inferred from whatever it's being assigned to.
-
list
public static <T> java.util.List<T> list(int capacity)
Makes a List with its generic type inferred from whatever it's being assigned to. Sets initial capacity accordingly.
-
list
@SafeVarargs public static <T,U extends T> java.util.List<T> list(U... contents)
Makes a List with its generic type inferred from whatever it's being assigned to filled with the items incontents
.
-
map
public static <K,V> java.util.Map<K,V> map()
Makes a Map using generic types inferred from whatever this is being assigned to.
-
identityHashMap
public static <K,V> java.util.Map<K,V> identityHashMap()
Makes an IdentityHashMap using generic types inferred from whatever this is being assigned to.
-
identityHashMap
public static <K,V> java.util.Map<K,V> identityHashMap(int capacity)
Makes an IdentityHashMap using generic types inferred from whatever this is being assigned to. Sets initial capacity accordingly.
-
concurrentMap
public static <K,V> java.util.concurrent.ConcurrentMap<K,V> concurrentMap()
Makes a ConcurrentMap using generic types inferred from whatever this is being assigned to.
-
set
public static <E> java.util.Set<E> set()
Makes a Set using the generic type inferred from whatever this is being assigned to.
-
linkedHashSet
public static <E> java.util.Set<E> linkedHashSet()
Makes a LinkedHashSet using the generic type inferred from whatever this is being assigned to.
-
linkedHashSet
public static <E> java.util.Set<E> linkedHashSet(int capacity)
Makes a LinkedHashSet using the generic type inferred from whatever this is being assigned to. Sets initial capacity accordingly.
-
set
@SafeVarargs public static <T,U extends T> java.util.Set<T> set(U... contents)
Makes a Set using the generic type inferred from whatever this is being assigned to filled with the items incontents
.
-
concurrentSet
public static <E> java.util.Set<E> concurrentSet()
Makes a Set, ensuring safe concurrent operations, using generic types inferred from whatever this is being assigned to.
-
-