class ApplicationV1Filter implements Filter {

    @Override
    public Promise<QueryResponse, ResourceException> filterQuery(final Context context,
            final QueryRequest request, final QueryResourceHandler handler, final RequestHandler next) {
        final List<ResourceResponse> resources = new ArrayList<>();
        // Forward onto next handler.
        return applicationTransformer.transform(next.handleQuery(context, request, new QueryResourceHandler() {
            @Override
            public boolean handleResource(ResourceResponse resource) {
                return resources.add(resource);
            }
        }), context, request, handler, resources);
    }

    @Inject public  ApplicationV1Filter(final ResourceTypeService resourceTypeService,
                               final ApplicationServiceFactory applicationServiceFactory,
                               final ExceptionMappingHandler<EntitlementException, ResourceException> resourceErrorHandler,
                               final ContextHelper contextHelper,
                               final ApplicationV1FilterTransformer applicationTransformer,
                               @Named("frRest") final Debug debug);

}