所以,我需要API的功能
interface BiFunction<A, B> {
B aToB(A input);
A bToA(B input);
}
Run Code Online (Sandbox Code Playgroud)
Guava是否提供了这样的smt.如果不是,你建议使用aToB/ bToA方法的名字?
截至 2014 年底,Guava 19.0 拥有:
https://google.github.io/guava/releases/19.0/api/docs/com/google/common/base/Converter.html
B b = Converter.convert(a);
A a = Converter.reverse().convert(b);
Run Code Online (Sandbox Code Playgroud)
您需要实现以下方法:
protected abstract A doBackward(B b)
protected abstract B doForward(A a)
Run Code Online (Sandbox Code Playgroud)