org.andromda.core.common
Class ExceptionUtils

java.lang.Object
  extended by org.andromda.core.common.ExceptionUtils

public class ExceptionUtils
extends Object

Contains Exception handling utilities.

Author:
Chad Brandon

Constructor Summary
ExceptionUtils()
           
 
Method Summary
static void checkAssignable(Class assignableToClass, String argumentName, Class argumentClass)
          Checks if the argumentClass is assignable to assignableToClass, and if not throws an IllegalArgumentException, otherwise does nothing.
static void checkAssignable(String methodExecuteName, Class assignableToClass, String argumentName, Class argumentClass)
          Deprecated. use checkAssignable(Class, String, Class) since we can detect the method name.
static void checkEmpty(String argumentName, String argument)
          Checks if the argument is null or an empty String throws an IllegalArgumentException if it is, does nothing if not.
static void checkEmpty(String methodExecuteName, String argumentName, String argument)
          Deprecated. use checkEmpty(String, String) instead since we can detect the method name.
static void checkNull(String argumentName, Object argument)
          Checks if the argument is null, and if so, throws an IllegalArgumentException, does nothing if not.
static void checkNull(String methodExecuteName, String argumentName, Object argument)
          Deprecated. used checkNull(String, Object) instead since we can detect the method name.
static Throwable getRootCause(Throwable throwable)
          Attempts to retrieve the root cause of the exception, if it can not be found, the throwable itself is returned.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExceptionUtils

public ExceptionUtils()
Method Detail

checkNull

public static void checkNull(String methodExecuteName,
                             String argumentName,
                             Object argument)
Deprecated. used checkNull(String, Object) instead since we can detect the method name.

Checks if the argument is null, and if so, throws an IllegalArgumentException, does nothing if not.

Parameters:
methodExecuteName - the name of the method we are currently executing
argumentName - the name of the argument we are checking for null
argument - the argument we are checking

checkNull

public static void checkNull(String argumentName,
                             Object argument)
Checks if the argument is null, and if so, throws an IllegalArgumentException, does nothing if not.

Parameters:
argumentName - the name of the argument we are checking for null
argument - the argument we are checking

checkEmpty

public static void checkEmpty(String methodExecuteName,
                              String argumentName,
                              String argument)
Deprecated. use checkEmpty(String, String) instead since we can detect the method name.

Checks if the argument is null or an empty String throws an IllegalArgumentException if it is, does nothing if not.

Parameters:
methodExecuteName - the name of the method we are currently executing
argumentName - the name of the argument we are checking for null
argument - the argument we are checking

checkEmpty

public static void checkEmpty(String argumentName,
                              String argument)
Checks if the argument is null or an empty String throws an IllegalArgumentException if it is, does nothing if not.

Parameters:
argumentName - the name of the argument we are checking for null
argument - the argument we are checking

checkAssignable

public static void checkAssignable(String methodExecuteName,
                                   Class assignableToClass,
                                   String argumentName,
                                   Class argumentClass)
Deprecated. use checkAssignable(Class, String, Class) since we can detect the method name.

Checks if the argumentClass is assignable to assignableToClass, and if not throws an IllegalArgumentException, otherwise does nothing.

Parameters:
methodExecuteName - the method name of the method, this method is being executed within
assignableToClass - the Class that argumentClass must be assignable to
argumentClass - the argumentClass we are checking
argumentName - the name of the argument we are checking

checkAssignable

public static void checkAssignable(Class assignableToClass,
                                   String argumentName,
                                   Class argumentClass)
Checks if the argumentClass is assignable to assignableToClass, and if not throws an IllegalArgumentException, otherwise does nothing.

Parameters:
assignableToClass - the Class that argumentClass must be assignable to
argumentClass - the argumentClass we are checking
argumentName - the name of the argument we are checking

getRootCause

public static Throwable getRootCause(Throwable throwable)
Attempts to retrieve the root cause of the exception, if it can not be found, the throwable itself is returned.

Parameters:
throwable - the exception from which to retrieve the root cause.
Returns:
the root cause of the exception


Copyright © 2003-2010 AndroMDA.org. All Rights Reserved.