Class AssignmentFilter

  • All Implemented Interfaces:
    Filter

    public class AssignmentFilter
    extends Object
    implements Filter
    Conditionally assigns values to expressions before and after the request is handled.
    • Constructor Detail

      • AssignmentFilter

        public AssignmentFilter()
    • Method Detail

      • addRequestBinding

        public AssignmentFilter addRequestBinding​(LeftValueExpression<?> target)
        Registers an unconditional (always executed) binding on the request flow. The value stored in the target will be null.
        Parameters:
        target - Expression that yields the target object whose value is to be set
        Returns:
        this object for fluent usage
      • addRequestBinding

        public AssignmentFilter addRequestBinding​(LeftValueExpression<?> target,
                                                  Expression<?> value)
        Registers an unconditional (always executed) binding on the request flow. The value stored in the target will be the result of the value Expression.
        Parameters:
        target - Expression that yields the target object whose value is to be set
        value - Expression that yields the value to be set in the target (may be null)
        Returns:
        this object for fluent usage
      • addRequestBinding

        public AssignmentFilter addRequestBinding​(Expression<Boolean> condition,
                                                  LeftValueExpression<?> target,
                                                  Expression<?> value)
        Registers a conditional binding on the request flow. If the condition is fulfilled, the value stored in the target will be the result of the value Expression.
        Parameters:
        condition - Condition to evaluate to determine if assignment should occur (may be null, aka unconditional)
        target - Expression that yields the target object whose value is to be set
        value - Expression that yields the value to be set in the target (may be null)
        Returns:
        this object for fluent usage
      • addResponseBinding

        public AssignmentFilter addResponseBinding​(LeftValueExpression<?> target)
        Registers an unconditional (always executed) binding on the response flow. The value stored in the target will be null.
        Parameters:
        target - Expression that yields the target object whose value is to be set
        Returns:
        this object for fluent usage
      • addResponseBinding

        public AssignmentFilter addResponseBinding​(LeftValueExpression<?> target,
                                                   Expression<?> value)
        Registers an unconditional (always executed) binding on the response flow. The value stored in the target will be the result of the value Expression.
        Parameters:
        target - Expression that yields the target object whose value is to be set
        value - Expression that yields the value to be set in the target (may be null)
        Returns:
        this object for fluent usage
      • addResponseBinding

        public AssignmentFilter addResponseBinding​(Expression<Boolean> condition,
                                                   LeftValueExpression<?> target,
                                                   Expression<?> value)
        Registers a conditional binding on the response flow. If the condition is fulfilled, the value stored in the target will be the result of the value Expression.
        Parameters:
        condition - Condition to evaluate to determine if assignment should occur (may be null, aka unconditional)
        target - Expression that yields the target object whose value is to be set
        value - Expression that yields the value to be set in the target (may be null)
        Returns:
        this object for fluent usage
      • filter

        public Promise<Response,​NeverThrowsException> filter​(Context context,
                                                                   Request request,
                                                                   Handler next)
        Description copied from interface: Filter
        Filters the request and/or response of an exchange. To pass the request to the next filter or handler in the chain, the filter calls next.handle(context, request).

        This method may elect not to pass the request to the next filter or handler, and instead handle the request itself. It can achieve this by merely avoiding a call to next.handle(context, request) and creating its own response object. The filter is also at liberty to replace a response with another of its own by intercepting the response returned by the next handler.

        Specified by:
        filter in interface Filter
        Parameters:
        context - The request context.
        request - The request.
        next - The next filter or handler in the chain to handle the request.
        Returns:
        A Promise representing the response to be returned to the client.