public class ConditionalFilter extends Object implements org.forgerock.http.Filter
Constructor and Description |
---|
ConditionalFilter(org.forgerock.http.Filter delegate,
org.forgerock.util.AsyncFunction<ContextAndRequest,Boolean,Exception> condition)
Constructs a
ConditionalFilter . |
ConditionalFilter(org.forgerock.http.Filter delegate,
boolean condition)
Constructs a
ConditionalFilter . |
Modifier and Type | Method and 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) |
public ConditionalFilter(org.forgerock.http.Filter delegate, boolean condition)
ConditionalFilter
.
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 :
if (condition) { return delegate; } else { return new Filter() {
delegate
- the filter that will be executed if the condition is true.condition
- the condition that controls the delegate filter's executionpublic ConditionalFilter(org.forgerock.http.Filter delegate, org.forgerock.util.AsyncFunction<ContextAndRequest,Boolean,Exception> condition)
ConditionalFilter
.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.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)
filter
in interface org.forgerock.http.Filter
Copyright © 2025 Open Identity Platform Community. All rights reserved.