Package org.zkoss.lang
Class Generics
- java.lang.Object
-
- org.zkoss.lang.Generics
-
public class Generics extends java.lang.Object
Utilities to handle generic types, such as converting a non-type object to a generic type without warning.- Since:
- 6.0.0
- Author:
- tomyeh
-
-
Constructor Summary
Constructors Constructor Description Generics()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.lang.Class<T>
cast(java.lang.Class cls)
Returns a type-safe generic class of the given type-less class.static <T> T
cast(java.lang.Object o)
Force to cast an object to the given type.static <T> java.lang.ThreadLocal<T>
cast(java.lang.ThreadLocal tl)
Returns a type-safe generic thread-local of the given un-typed thread-local.static <T> java.util.Collection<T>
cast(java.util.Collection col)
Returns a type-safe generic collection of the given un-typed collection.static <T> java.util.Enumeration<T>
cast(java.util.Enumeration en)
Returns a type-safe generic enumeration of the given un-typed enumeration.static <T> java.util.Iterator<T>
cast(java.util.Iterator it)
Returns a type-safe generic iterator of the given un-typed iterator.static <T> java.util.List<T>
cast(java.util.List list)
Returns a type-safe generic list of the given un-typed list.static <T> java.util.ListIterator<T>
cast(java.util.ListIterator it)
Returns a type-safe generic list iterator of the given un-typed list iterator.static <K,V>
java.util.Map<K,V>cast(java.util.Map map)
Returns a type-safe generic map of the given un-typed map.static <T> java.util.Set<T>
cast(java.util.Set set)
Returns a type-safe generic set of the given un-typed set.
-
-
-
Method Detail
-
cast
public static final <T> java.lang.Class<T> cast(java.lang.Class cls)
Returns a type-safe generic class of the given type-less class.
-
cast
public static final <T> T cast(java.lang.Object o)
Force to cast an object to the given type. Notice that it is not safe to use, unless you are sure thato
is an instance of T.
-
cast
public static final <T> java.util.Iterator<T> cast(java.util.Iterator it)
Returns a type-safe generic iterator of the given un-typed iterator.
-
cast
public static final <T> java.util.ListIterator<T> cast(java.util.ListIterator it)
Returns a type-safe generic list iterator of the given un-typed list iterator.
-
cast
public static final <T> java.util.Enumeration<T> cast(java.util.Enumeration en)
Returns a type-safe generic enumeration of the given un-typed enumeration.
-
cast
public static final <T> java.util.Collection<T> cast(java.util.Collection col)
Returns a type-safe generic collection of the given un-typed collection.
-
cast
public static final <T> java.util.List<T> cast(java.util.List list)
Returns a type-safe generic list of the given un-typed list.
-
cast
public static final <T> java.util.Set<T> cast(java.util.Set set)
Returns a type-safe generic set of the given un-typed set.
-
cast
public static final <K,V> java.util.Map<K,V> cast(java.util.Map map)
Returns a type-safe generic map of the given un-typed map.
-
cast
public static final <T> java.lang.ThreadLocal<T> cast(java.lang.ThreadLocal tl)
Returns a type-safe generic thread-local of the given un-typed thread-local.
-
-