首先,很抱歉标题不好,但我发现很难用一句话概括我的问题......
我们的软件中有一些代码我非常不满意。事情是这样的:
@FunctionalInterface
public interface OneArgCall<T, U, A> {
T execute(U u, A arg);
}
@FunctionalInterface
public interface TwoArgCall<T, U, A, B> {
T execute(U u, A arg, B arg2);
}
public <T, U, A, B> T execCall(String x, Class<U> c, OneArgCall<T, U, A> call, A arg) {
U u = doSomething(x, c);
try {
return call.execute(u, arg);
} catch (SomeException se) {
handleSe(se);
} catch (SomeOtherException soe) {
handleSoe(soe);
}
public <T, U, A, B> T execCall(String x, Class<P> …Run Code Online (Sandbox Code Playgroud)