Package org.forgerock.http.filter
Class ConditionalFilter
- java.lang.Object
-
- org.forgerock.http.filter.ConditionalFilter
-
- All Implemented Interfaces:
org.forgerock.http.Filter
public class ConditionalFilter extends Object implements org.forgerock.http.Filter
This filter conditionally executes a delegate Filter given the result of a 'condition' function. If the condition is true then the delegated filter is executed, skipped otherwise.
-
-
Constructor Summary
Constructors Constructor Description ConditionalFilter(org.forgerock.http.Filter delegate, boolean condition)Constructs aConditionalFilter.ConditionalFilter(org.forgerock.http.Filter delegate, org.forgerock.util.AsyncFunction<ContextAndRequest,Boolean,Exception> condition)Constructs aConditionalFilter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.forgerock.util.promise.Promise<org.forgerock.http.protocol.Response,org.forgerock.util.promise.NeverThrowsException>filter(org.forgerock.services.context.Context context, org.forgerock.http.protocol.Request request, org.forgerock.http.Handler next)
-
-
-
Constructor Detail
-
ConditionalFilter
public ConditionalFilter(org.forgerock.http.Filter delegate, boolean condition)Constructs aConditionalFilter.This constructor is provided as an ease to write some code : since you have access to the boolean, you may optimise the code like this :
{@code if (condition) { return delegate; } else { return new Filter() {- Parameters:
delegate- the filter that will be executed if the condition is true.condition- the condition that controls the delegate filter's execution
-
ConditionalFilter
public ConditionalFilter(org.forgerock.http.Filter delegate, org.forgerock.util.AsyncFunction<ContextAndRequest,Boolean,Exception> condition)Constructs aConditionalFilter.- Parameters:
delegate- the filter that will be executed if the condition is true.condition- the function that will be executed at each request and will allow or not to execute the delegate filter.
-
-
Method Detail
-
filter
public org.forgerock.util.promise.Promise<org.forgerock.http.protocol.Response,org.forgerock.util.promise.NeverThrowsException> filter(org.forgerock.services.context.Context context, org.forgerock.http.protocol.Request request, org.forgerock.http.Handler next)- Specified by:
filterin interfaceorg.forgerock.http.Filter
-
-