org.zkoss.lang
Class Generics

java.lang.Object
  extended by 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
Generics()
           
 
Method Summary
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> 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> T
cast(java.lang.Object o)
          Force to cast an object to the given type.
static
<T> java.util.Set<T>
cast(java.util.Set set)
          Returns a type-safe generic set of the given un-typed set.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Generics

public Generics()
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 that o 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.



Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo