org.virtualmock.util
Class PrimitiveUtils

java.lang.Object
  extended byorg.virtualmock.util.PrimitiveUtils

public class PrimitiveUtils
extends java.lang.Object

Provides utilities for working with primitives. The getDefaultPrimitiveValue() method generates default return values for primitives. The getPrimitiveTypeForWrapperClass method converts a primitive wrapper class (such as Integer.class) into a primitive class (such as int.class).

Version:
$Revision: 1.3 $
Author:
Chad Woolley

Constructor Summary
PrimitiveUtils()
           
 
Method Summary
 java.lang.Object getDefaultPrimitiveValue(java.lang.Class type)
          Generate default return values for specified primitive type.
 java.lang.Class getPrimitiveTypeForWrapperClass(java.lang.Class primitiveWrapperType)
          When passed a primitive wrapper type (such as Integer.class), returns the corresponding primitive type (such as int.class).
 boolean isAssignableToPrimitiveWrapper(java.lang.Class type)
          Returns true if the specified type is assignable to any primitive type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrimitiveUtils

public PrimitiveUtils()
Method Detail

isAssignableToPrimitiveWrapper

public boolean isAssignableToPrimitiveWrapper(java.lang.Class type)
Returns true if the specified type is assignable to any primitive type.

Parameters:
type - the type to check for assignability to a primitive type
Returns:
Returns true if the specified type is assignable to any primitive type

getDefaultPrimitiveValue

public java.lang.Object getDefaultPrimitiveValue(java.lang.Class type)
Generate default return values for specified primitive type.

Parameters:
type - a Class object representing a primitive
Returns:
the default value for the primitive
Throws:
java.lang.IllegalArgumentException - if the type is not a primitive

getPrimitiveTypeForWrapperClass

public java.lang.Class getPrimitiveTypeForWrapperClass(java.lang.Class primitiveWrapperType)
When passed a primitive wrapper type (such as Integer.class), returns the corresponding primitive type (such as int.class).

Parameters:
primitiveWrapperType - The primitive wrapper class to convert to a primitive class
Returns:
the primitive class corresponding to the primitive wrapper class
Throws:
java.lang.IllegalArgumentException - if the specified type is not one of the eight primitive wrapper types


Copyright © 2003-2005 Virtual Mock. All Rights Reserved.