public class FallbackMethod
extends java.lang.Object
Throwable. When fallback(Throwable)
is invoked, Throwable will be passed to that last parameter. If there are multiple
fallback method, one of the methods that has most closest superclass parameter of thrown object
will be invoked.
For example, there are two fallback methodsString fallbackMethod(String parameter, RuntimeException exception) String fallbackMethod(String parameter, IllegalArgumentException exception)and if try to fallback fromNumberFormatException,String fallbackMethod(String parameter, IllegalArgumentException exception)will be invoked.
| Modifier and Type | Method and Description |
|---|---|
static FallbackMethod |
create(java.lang.String fallbackMethodName,
java.lang.reflect.Method originalMethod,
java.lang.Object[] args,
java.lang.Object target) |
java.lang.Object |
fallback(java.lang.Throwable thrown)
try to fallback from
Throwable |
java.lang.Class<?> |
getReturnType()
get return type of fallbackMethod method
|
public static FallbackMethod create(java.lang.String fallbackMethodName, java.lang.reflect.Method originalMethod, java.lang.Object[] args, java.lang.Object target) throws java.lang.NoSuchMethodException
fallbackMethodName - the configured fallback method nameoriginalMethod - the original method which has fallback method configuredargs - the original method argumentstarget - the target class that own the original method and fallback methodjava.lang.NoSuchMethodException@Nullable
public java.lang.Object fallback(java.lang.Throwable thrown)
throws java.lang.Throwable
Throwablethrown - Throwable that should be fallbackjava.lang.Throwable - if throwable is unrecoverable, throwable will be thrownpublic java.lang.Class<?> getReturnType()