org.spicefactory.cinnamon.reflect
Class ConversionException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by org.spicefactory.cinnamon.reflect.ConversionException
All Implemented Interfaces:
Serializable

public class ConversionException
extends RuntimeException

Exception thrown when type conversion fails.

Author:
Jens Halm
See Also:
Serialized Form

Constructor Summary
ConversionException(Object value, Type targetType)
          Creates a new ConversionException
ConversionException(Object value, Type targetType, String message)
          Creates a new ConversionException
ConversionException(Object value, Type targetType, String message, Throwable cause)
          Creates a new ConversionException
ConversionException(Object value, Type targetType, Throwable cause)
          Creates a new ConversionException
 
Method Summary
 Type getGenericTargetType()
          Returns the generic target type of the failed conversion.
 Class<?> getRawTargetType()
          Returns the raw target type of the failed conversion.
 Object getValue()
          Returns the original value that cannot be converted to the target type.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConversionException

public ConversionException(Object value,
                           Type targetType)
Creates a new ConversionException

Parameters:
value - the value that could not be converted
targetType - the target type that the specified value should have been converted to

ConversionException

public ConversionException(Object value,
                           Type targetType,
                           Throwable cause)
Creates a new ConversionException

Parameters:
value - the value that could not be converted
targetType - the target type that the specified value should have been converted to
cause - the root cause

ConversionException

public ConversionException(Object value,
                           Type targetType,
                           String message)
Creates a new ConversionException

Parameters:
value - the value that could not be converted
targetType - the target type that the specified value should have been converted to
message - the error message

ConversionException

public ConversionException(Object value,
                           Type targetType,
                           String message,
                           Throwable cause)
Creates a new ConversionException

Parameters:
value - the value that could not be converted
targetType - the target type that the specified value should have been converted to
message - the error message
cause - the root cause
Method Detail

getGenericTargetType

public Type getGenericTargetType()
Returns the generic target type of the failed conversion.

Returns:
the generic target type of the failed conversion

getRawTargetType

public Class<?> getRawTargetType()
Returns the raw target type of the failed conversion. For a ParameterizedType this will be the Class returned by ParameterizedType.getRawType. For a TypeVariable it will be the raw type of the Type returned by getBounds. An instance of Class will be returned unchanged.

Returns:
the raw target type of the failed conversion

getValue

public Object getValue()
Returns the original value that cannot be converted to the target type.

Returns:
the original value that cannot be converted to the target type