net.winterly.rxjersey.server.RxInvocationHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core-server Show documentation
Show all versions of core-server Show documentation
RxJava extension for Jersey and Dropwizard
package net.winterly.rxjersey.server;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
/**
* Typed invocation handler that supports result conversion
*
* @param Method result type
* @param Required type
*/
public interface RxInvocationHandler extends InvocationHandler {
@SuppressWarnings("unchecked")
@Override
default Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return convert((R) method.invoke(proxy, args));
}
/**
* Converts method result into object of required type
*
* @param result method call result
* @return converted value
* @throws Throwable same as {@link InvocationHandler#invoke(Object, Method, Object[])}
*/
T convert(R result) throws Throwable;
}