code/app/be/objectify/deadbolt/java/filters/FilterConstraints.java
public FilterFunction composite(final Constraint constraint,
                                    final Optional<String> content)
    {
        return (Http.RequestHeader requestHeader,
                DeadboltHandler handler,
                Function<Http.RequestHeader, CompletionStage<Result>> next) ->
                beforeAuthCheckCache.apply(handler, requestHeader, content)
                       .thenCompose(maybePreAuth -> maybePreAuth._1.map(preAuthResult -> (CompletionStage<Result>) CompletableFuture.completedFuture(preAuthResult))
                                                                .orElseGet(() -> constraint.test(maybePreAuth._2,
                                                                                                 handler)
                                                                                           .thenCompose(allowed -> allowed._1 ? ((Supplier<CompletionStage<Result>>) () -> {
                                                                                               handler.onAuthSuccess(allowed._2,
                                                                                                                     "composite",
                                                                                                                     ConstraintPoint.FILTER);
                                                                                               return next.apply(allowed._2);
                                                                                           }).get()
                                                                                                                           : handler.onAuthFailure(maybePreAuth._2,
                                                                                                                                                   content))));
    }
public FilterFunction composite(final Constraint constraint,
                                    final Optional<String> content)
    {
        return (Http.RequestHeader requestHeader,
                DeadboltHandler handler,
                Function<Http.RequestHeader, CompletionStage<Result>> next) ->
                beforeAuthCheckCache.apply(handler, requestHeader, content)
                       .thenCompose(maybePreAuth -> maybePreAuth._1.map(preAuthResult -> (CompletionStage<Result>) CompletableFuture.completedFuture(preAuthResult))
                                                                .orElseGet(() -> constraint.test(maybePreAuth._2,
                                                                                                 handler)
                                                                                           .thenCompose(allowed -> allowed._1 ? ((Supplier<CompletionStage<Result>>) () -> {
                                                                                               handler.onAuthSuccess(allowed._2,
                                                                                                                     "composite",
                                                                                                                     ConstraintPoint.FILTER);
                                                                                               return next.apply(allowed._2);
                                                                                           }).get()
                                                                                                                           : handler.onAuthFailure(maybePreAuth._2,
                                                                                                                                                   content))));
    }
A constraint that uses a {@link Constraint} to determine access.  This may be an arbitrarily complex
tree of constraints.

@param constraint the composite constraint
@param content    is passed to {@link DeadboltHandler#onAuthFailure(Http.RequestHeader, Optional)} if the authorization fails
@return a function that wraps the constraint