Created
September 20, 2013 19:48
-
-
Save pettyjamesm/6642863 to your computer and use it in GitHub Desktop.
Converting a play! 2.2.0 Promise<Result> to Promise<SimpleResult> in Java.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class PrescreenedAction extends Action<Prescreen>{ | |
@Override | |
public final Promise<SimpleResult> call(final Context context) throws Throwable { | |
final Promise<Result> screened = AccentureController.prescreenActiveSession(context.request()); | |
if (screened != null){ | |
return screened.flatMap(new Function<Result, Promise<SimpleResult>>(){ | |
@Override | |
public final Promise<SimpleResult> apply(final Result result) throws Throwable { | |
return Promise.wrap(result.getWrappedResult()).flatMap(new Function<play.api.mvc.SimpleResult,Promise<SimpleResult>>(){ | |
@Override | |
public final Promise<SimpleResult> apply(final play.api.mvc.SimpleResult scalaResult) throws Throwable { | |
return Promise.pure(((SimpleResult)new SimpleResult(){ | |
@Override | |
public final play.api.mvc.SimpleResult getWrappedSimpleResult() { | |
return scalaResult; | |
} | |
})); | |
} | |
}); | |
} | |
}); | |
} | |
return delegate.call(context); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment