This implies the creation of query statements from the criteria which can be applied to data sinks; such as databases (SQL like statements). In turn, this also implies parsing of criteria trees from a query statement (provided as logical operators in your code). Such parsable query statement can look as follows:
( ( ( City = 'Berlin' ) OR ( City = 'Munich' ) ) AND ( Surname = 'Miller' ) )A dedicated CriteriaFactory implementation is required (and already provided) for parsing the above query statement.
The refcodes-criteria framework consists of the following components:
A Criteria represents an atomic query or atomic logical operator with which complex queries can be constructed in an object oriented manner by combining the Criteria instances in a tree structure. From this tree structure, query statements can be generated. In turn, a query statement provided as logical operators can be parsed for the construction of a Criteria tree (see example above)s.
This means that a Criteria query is constructed from a Criteria tree with CriteriaNode node instances and CriteriaLeaf leaf instances. A node may contain other node instances and/or other leaf instances, all of which being the node's children.
CriteriaNode
:CriteriaLeaf
:SingleCriteriaNode
:Criteria
:CriteriaSugar
:
import static org.refcodes.criteria.CriteriaSugar.*;
...
Criteria theCriteria = and( or( equalWith( "City", "Berlin" ), equalWith( "City", "Munich" ) ), equalWith( "Surname", "Miller" ) );
...
CriteriaFactory
:( ( ( City = 'Berlin' ) OR ( City = 'Munich' ) ) AND ( Surname = 'Miller' ) )CAUTION: The syntax supported for the query statement is implementation depended!
The ExpressionCriteriaFactoryImpl implements a CriteriaFactory being capable of parsing the above query.
QueryFactory
:CAUTION: The syntax supported for the query statement is implementation depended!
Interface | Description |
---|---|
AndCriteria |
A
CriteriaNode representing a logical AND
operator. |
Criteria |
The
Criteria itself is the base definition of
functionality which the CriteriaNode and
CriteriaLeaf implementations are to support. |
CriteriaAccessor |
Provides an accessor for a
Criteria property. |
CriteriaAccessor.CriteriaMutator |
Provides a mutator for a
Criteria property. |
CriteriaAccessor.CriteriaProperty |
Provides a
Criteria property. |
CriteriaFactory<Q> |
The
CriteriaFactory constructs a
Criteria (tree) from the provided query. |
CriteriaLeaf<T> |
A CriteriaLeaf tree leaf is an expression usually relating to a key (for
example identifying a table's column in a database) and a value, both of
which consolidating an expression (for example "City = 'Munich'").
|
CriteriaNode |
A CriteriaNode tree node may represent a logical AND or a logical OR or a
logical NOT applied on the node's children Criteria (CriteriaNode instances
and CriteriaLeaf instances).
|
EqualWithCriteria<T> |
A
CriteriaLeaf representing a EQUAL WITH
expression. |
GreaterOrEqualThanCriteria<T> |
A
CriteriaLeaf representing a GREATER OR EQUAL
THAN expression. |
GreaterThanCriteria<T> |
A
CriteriaLeaf representing a GREATER THAN
expression. |
IntersectWithCriteria |
A
CriteriaNode representing a logical INTERSECT
operator. |
LessOrEqualThanCriteria<T> |
A
CriteriaLeaf representing a LESS OR EQUAL
THAN expression. |
LessThanCriteria<T> |
A
CriteriaLeaf representing a LESS THAN
expression. |
NotCriteria |
A
CriteriaNode representing a logical NOT
operator. |
NotEqualWithCriteria<T> |
A
CriteriaLeaf representing a NOT EQUAL WITH
expression. |
OrCriteria |
A
CriteriaNode representing a logical OR
operator. |
PartitionQueryFactory<Q,PS> |
The
PartitionQueryFactory is a specialization
of the QueryFactory in that it is capable of
generating queries targeting at a dedicated partition of a (database)
cluster, the partion's query does not contain obsolete query statements
enhancing the database's query processing performance. |
QueryFactory<Q> |
The
QueryFactory generates a query from the
provided Criteria (tree). |
SingleCriteriaNode |
A special specialization of the
CriteriaNode ,
allowing just one child. |
Class | Description |
---|---|
AbstractCriteria | |
AbstractCriteriaLeaf<T> |
Base class with the base
CriteriaLeaf
functionality provided for CriteriaLeaf
implementations. |
AbstractCriteriaNode |
Base class with the base
CriteriaNode
functionality provided for CriteriaNode
implementations. |
AbstractSingleCriteriaNode |
Base class with the base
SingleCriteriaNode
functionality provided for SingleCriteriaNode
implementations. |
CriteriaSugar |
Declarative syntactic sugar which may be statically imported in order to
allow declarative definitions of
Criteria
trees: ... |
CriteriaUtility |
The Class CriteriaUtility.
|
ExpressionCriteriaFactoryImpl |
Implements a
CriteriaFactory which is capable
of parsing an expression such as the following one: ( ( ( City = 'Berlin' )
OR ( City = 'Munich' ) ) AND ( Surname = 'Miller' ) ). |
ExpressionQueryFactoryImpl |
The
ExpressionCriteriaFactoryImpl is capable of
creating query String instances from
Criteria instances; the query
String instances which can be used as parts of SQL
statements. |
Exception | Description |
---|---|
ComplexCriteriaException |
The Class ComplexCriteriaException.
|
CriteriaException |
The Class CriteriaException.
|
CriteriaRuntimeException |
The Class CriteriaRuntimeException.
|
UnknownCriteriaRuntimeException |
The Class UnknownCriteriaRuntimeException.
|
Copyright © 2021. All rights reserved.