- Type Parameters:
R
- the type of resources to filter.
- Enclosing class:
Optimization
Filter that can be optimized. Each filter implementation knows which rules can be applied.
For that reason, the optimization algorithms are kept in each implementation class.
This interface allows
Optimization
to invoke that code.
Implementations need to override only one of the 2 methods defined in this interface.
-
Method Summary
Modifier and TypeMethodDescriptionReturns theAND
logical operation between this filter and the given predicate.negate()
Returns the logical negation of this filter.optimize
(Optimization optimization) Tries to optimize this filter.Returns theOR
logical operation between this filter and the given predicate.recreate
(Expression<R, ?>[] effective) Creates a new filter of the same type and parameters than this filter, except for the expressions.Methods inherited from interface Filter
getExpressions, getOperatorType, getResourceClass, test
-
Method Details
-
optimize
Tries to optimize this filter. The default implementation performs the following steps:- If all expressions are literals, evaluate this filter immediately.
- Otherwise if at least one child expression can be optimized, recreate the filter.
- Otherwise returns
this
.
- Parameters:
optimization
- the simplifications or optimizations to apply on this filter.- Returns:
- the simplified or optimized filter, or
this
if no optimization has been applied.
-
recreate
Creates a new filter of the same type and parameters than this filter, except for the expressions. The expressions given to this method shall be equivalent to the expressions used by this filter, potentially more efficient.This method is used by the default implementation of
optimize(Optimization)
and can be ignored if above method is overridden.- Parameters:
effective
- the expressions to use as a replacement of this filter expressions.- Returns:
- the new filter, or
this
if unsupported.
-
and
Returns theAND
logical operation between this filter and the given predicate. If the given predicate is an instance ofFilter<R>
, then the returned predicate is also an instance ofFilter<R>
. -
or
Returns theOR
logical operation between this filter and the given predicate. If the given predicate is an instance ofFilter<R>
, then the returned predicate is also an instance ofFilter<R>
. -
negate
Returns the logical negation of this filter. The returned predicate is an instance ofOptimization.OnFilter
.
-