net.sf.qualitytest.blueprint
Class SafeInvoke
java.lang.Object
net.sf.qualitytest.blueprint.SafeInvoke
public final class SafeInvoke
- extends Object
Invoke a method or execute code without having to care for checked (and unchecked) exceptions. All exceptions can be
converted to a defined runtime exception.
- Author:
- Dominik Seichter
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
invoke
public static <T> T invoke(@Nonnull
SafeInvoke.ExceptionRunnable<T> runnable,
@Nonnull
Class<? extends RuntimeException> exceptionClass)
- Safely invoke a method on an object without having to care about checked exceptions. The runnable is executed and
every exception is converted into a
BlueprintException
.
- Parameters:
runnable
- An ExceptionRunnable
exceptionClass
- The kind of exception that should be thrown. If the thrown exception is not a subclass of this class,
a new instance is created
- Throws:
Throwable
BlueprintException
- in case of any error
Copyright © 2012-2013. All Rights Reserved.