Lima-Loa

org.limaloa
Class ExceptionMapping

java.lang.Object
  extended by org.limaloa.ExceptionMapping

public final class ExceptionMapping
extends java.lang.Object

Encapsulates an Exception Mapping. Designed as an immutable value object.

Author:
Chris Nappin

Constructor Summary
ExceptionMapping(java.lang.Class<? extends java.lang.Throwable> sourceClass, java.lang.Class<? extends java.lang.Throwable> targetClass)
          Creates a new exception, with wrapping enabled.
ExceptionMapping(java.lang.Class<? extends java.lang.Throwable> sourceClass, java.lang.Class<? extends java.lang.Throwable> targetClass, boolean wrap)
          Creates a new exception.
ExceptionMapping(java.lang.String sourceClassname, java.lang.String targetClassname)
          Creates a new exception, with wrapping enabled.
ExceptionMapping(java.lang.String sourceClassname, java.lang.String targetClassname, boolean wrap)
          Creates a new exception, with wrapping enabled.
 
Method Summary
 boolean equals(java.lang.Object object)
          Value equality.
 java.lang.Class<? extends java.lang.Throwable> getSource()
          Get the source exception.
 java.lang.Class<? extends java.lang.Throwable> getTarget()
          Get the target exception.
 boolean getWrap()
          Get whether the original exception should be wrapped upon mapping.
 int hashCode()
          Hash code, consistent with value equality.
 java.lang.String toString()
          Converts an instance to a string.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExceptionMapping

public ExceptionMapping(java.lang.String sourceClassname,
                        java.lang.String targetClassname)
                 throws java.lang.ClassNotFoundException,
                        java.lang.ClassCastException
Creates a new exception, with wrapping enabled.

Parameters:
sourceClassname - The source exception classname
targetClassname - The target exception classname
Throws:
java.lang.ClassNotFoundException - Unable to find source or target class
java.lang.ClassCastException - If source or target is not an exception

ExceptionMapping

public ExceptionMapping(java.lang.Class<? extends java.lang.Throwable> sourceClass,
                        java.lang.Class<? extends java.lang.Throwable> targetClass)
Creates a new exception, with wrapping enabled.

Parameters:
sourceClass - The source exception class
targetClass - The target exception class

ExceptionMapping

public ExceptionMapping(java.lang.String sourceClassname,
                        java.lang.String targetClassname,
                        boolean wrap)
                 throws java.lang.ClassNotFoundException,
                        java.lang.ClassCastException
Creates a new exception, with wrapping enabled.

Parameters:
sourceClassname - The source exception classname
targetClassname - The target exception classname
wrap - Whether to wrap the original exception upon mapping
Throws:
java.lang.ClassNotFoundException - Unable to find source or target class
java.lang.ClassCastException - If source or target is not an exception

ExceptionMapping

public ExceptionMapping(java.lang.Class<? extends java.lang.Throwable> sourceClass,
                        java.lang.Class<? extends java.lang.Throwable> targetClass,
                        boolean wrap)
Creates a new exception.

Parameters:
sourceClass - The source exception class
targetClass - The target exception class
wrap - Whether to wrap the original exception upon mapping
Method Detail

getSource

public java.lang.Class<? extends java.lang.Throwable> getSource()
Get the source exception.

Returns:
the exception

getTarget

public java.lang.Class<? extends java.lang.Throwable> getTarget()
Get the target exception.

Returns:
the exception

getWrap

public boolean getWrap()
Get whether the original exception should be wrapped upon mapping.

Returns:
true if to wrap original exception

equals

public boolean equals(java.lang.Object object)
Value equality.

Overrides:
equals in class java.lang.Object
Parameters:
object - The object to compare
Returns:
true if of equal value

hashCode

public int hashCode()
Hash code, consistent with value equality.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code

toString

public java.lang.String toString()
Converts an instance to a string.

Overrides:
toString in class java.lang.Object
Returns:
The string representation

Lima-Loa