Skip to content

Instantly share code, notes, and snippets.

@johntrimble
Created March 2, 2012 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johntrimble/1954826 to your computer and use it in GitHub Desktop.
Save johntrimble/1954826 to your computer and use it in GitHub Desktop.
Wrapping functions in Java sucks.
public <A,B> Function<Function<A,B>, Function<A,B>> requiresTx() {
return new Function<Function<A,B>, Function<A,B>>() {
@Override
public Function<A,B> apply(final Function<A,B> f) {
return new Function<A,B>() {
public B apply(final A a) {
return txService.required(new Callable<B>() {
public B call() throws Exception {
return f.apply(a);
};
});
};
};
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment