Package com.github.mhewedy.expressions
Class Expression
java.lang.Object
com.github.mhewedy.expressions.Expression
Expression class considered the base for all other expressions as well as contains
factory method to build the expressions object.
So it represents the java api for the expressions
Example:
We can build complex expressions and pass it to the spring data jpa ExpressionsRepository.findAll(Expressions)
using the factory methods in this class as following:
var expressions = Expression.of("lastName", Operator.$eq, "ibrahim") .and(Expression.or( Expression.of("age", Operator.$in, 10, 20), Expression.of("birthDate", Operator.$lt, LocalDate.of(1980, 1, 1))) ).build();Then the output could be represented as:
where lastName = "ibrahim" and (age in (10 , 20) or birth_date < "1980-01-01")
The Expression API also service as an intermediate representations that resides between
the Expressions
and the spring data JPA specifications
implementation ExpressionsPredicateBuilder
.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionand
(Expression expression) apply "and" on current expression with the parameter expression.static Expression
and
(Expression... expressions) factory method used to create new expression that "and" all input expressions.build()
Convert current object toExpressions
to be used by theExpressionsRepository
.static Expression
static Expression
Used with operators require list of elements, such asOperator.$in
andOperator.$nin
static Expression
static Expression
Used with operators require list of elements, such asOperator.$in
andOperator.$nin
static Expression
static Expression
Used with operators require list of elements, such asOperator.$in
andOperator.$nin
static Expression
static Expression
Used with operators require list of elements, such asOperator.$in
andOperator.$nin
static Expression
static Expression
Used with operators require list of elements, such asOperator.$in
andOperator.$nin
static Expression
Used with operators require list of elements, such asOperator.$in
andOperator.$nin
or
(Expression expression) apply "or" on current expression with the parameter expression.static Expression
or
(Expression... expressions) factory method used to create new expression that "or" all input expressions.
-
Constructor Details
-
Expression
public Expression()
-
-
Method Details
-
of
-
of
-
of
-
of
-
of
-
of
Used with operators require list of elements, such asOperator.$in
andOperator.$nin
-
of
Used with operators require list of elements, such asOperator.$in
andOperator.$nin
-
of
Used with operators require list of elements, such asOperator.$in
andOperator.$nin
-
of
Used with operators require list of elements, such asOperator.$in
andOperator.$nin
-
of
Used with operators require list of elements, such asOperator.$in
andOperator.$nin
-
of
Used with operators require list of elements, such asOperator.$in
andOperator.$nin
-
and
factory method used to create new expression that "and" all input expressions. -
or
factory method used to create new expression that "or" all input expressions. -
and
apply "and" on current expression with the parameter expression. -
or
apply "or" on current expression with the parameter expression. -
build
Convert current object toExpressions
to be used by theExpressionsRepository
.
-