org.jboss.solder.reflection
Class PrimitiveTypes

java.lang.Object
  extended by org.jboss.solder.reflection.PrimitiveTypes

public final class PrimitiveTypes
extends java.lang.Object

Contains static utility methods for boxing and unboxing primitive types and their corresponding wrapper types.

Adopted from the Primitives class in the Guava libraries project.

Author:
Kevin Bourrillion

Method Summary
static java.util.Set<java.lang.Class<?>> allPrimitiveTypes()
          Returns an immutable set of all nine primitive types (including void).
static java.util.Set<java.lang.Class<?>> allWrapperTypes()
          Returns an immutable set of all nine primitive-wrapper types (including Void).
static
<T> java.lang.Class<T>
box(java.lang.Class<T> type)
          Returns the corresponding wrapper type of type if it is a primitive type; otherwise returns type itself.
static boolean isWrapperType(java.lang.Class<?> type)
          Returns true if type is one of the nine primitive-wrapper types, such as Integer.
static
<T> java.lang.Class<T>
unbox(java.lang.Class<T> type)
          Returns the corresponding primitive type of type if it is a wrapper type; otherwise returns type itself.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

allPrimitiveTypes

public static java.util.Set<java.lang.Class<?>> allPrimitiveTypes()
Returns an immutable set of all nine primitive types (including void). Note that a simpler way to test whether a Class instance is a member of this set is to call Class.isPrimitive().


allWrapperTypes

public static java.util.Set<java.lang.Class<?>> allWrapperTypes()
Returns an immutable set of all nine primitive-wrapper types (including Void).


isWrapperType

public static boolean isWrapperType(java.lang.Class<?> type)
Returns true if type is one of the nine primitive-wrapper types, such as Integer. This complements the JDK method Class.isPrimitive().

See Also:
Class.isPrimitive()

box

public static <T> java.lang.Class<T> box(java.lang.Class<T> type)
Returns the corresponding wrapper type of type if it is a primitive type; otherwise returns type itself. Idempotent.
     box(int.class) == Integer.class
     box(Integer.class) == Integer.class
     box(String.class) == String.class
 


unbox

public static <T> java.lang.Class<T> unbox(java.lang.Class<T> type)
Returns the corresponding primitive type of type if it is a wrapper type; otherwise returns type itself. Idempotent.
     unbox(Integer.class) == int.class
     unbox(int.class) == int.class
     unbox(String.class) == String.class
 



Copyright © 2008-2012 Seam Framework. All Rights Reserved.