How do I create Function1 object for use in flatMap method of finagle's Future object in Java?
Tried this:
Function1<String, String> f = new Function1<String, String>() {
@Override
public String apply(String s) {
return null;
}
};
But it doesn't work:
Error:(22, 73) java: is not abstract and does not override abstract method andThen$mcVJ$sp(scala.Function1) in scala.Function1
For the sake of completeness, here's the answer from my two month-old comment above.
First for some imports:
And now you only have to define the
apply
method:If you're using Finagle, though, Twitter's Util library also provides a similar helper class:
And then:
This latter option is probably better—I've never really liked explicitly using stuff from
scala.runtime
.