Class Criteria
- All Implemented Interfaces:
Cloneable
Criterion and aims to create a criterion's set to define how the values should be treated and what clauses must be created for specific fields.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Criterionprotected Criterionstatic final CriteriaIt's a predefinedCriteriaand it's used to define the content of the INSERT's SET clause.
This Criteria discard control fields and empty or null values.
For the others uses the EQUALS criterion.static final Criteriastatic final Criteriastatic final Criteriastatic final CriteriaDefines an empty Criteria used as starting point for your custom criteria.static final CriteriaIt's a predefinedCriteriaand it's used to define the content of the UPDATE?Fields inherited from class overit.geocall.sql.code.criterion.Criterion
ASSIGN_NULL, DIFFERENT, DISCARD, DISCARD_CONTROLS, DISCARD_NULLS, DISCARD_USELESS_COLLECTION, DISCARD_USELESS_LIKE, DISCARD_USELESS_SET, DISCARD_USELESS_STRING, EMPTY_SET, EQUAL, GREATER, GREATEREQUAL, IN, IS, ISNOT, ISNOTNULL, ISNULL, LESS, LESSEQUAL, LIKE, NOT_EQUAL, NOTIN, NULL_SET, REQUIRE_IS_DIFFERENT, REQUIRE_IS_EQUAL_TO, REQUIRE_IS_GREATER_THAN, REQUIRE_IS_GREATER_THAN_OR_EQUAL_TO, REQUIRE_IS_IN, REQUIRE_IS_LESS_THAN, REQUIRE_IS_LESS_THAN_OR_EQUAL_TO, REQUIRE_IS_LIKE, REQUIRE_IS_NOT_IN, REQUIRE_IS_NOT_NULL, REQUIRE_IS_NULL, RESET_EMPTY_SET, TAKE_EMPTY_COLLECTION, TAKE_EMPTY_SET, TAKE_IN, TAKE_IS_NULL, TAKE_LIKE, USELESS_COLLECTION, USELESS_LIKE, USELESS_SET, USELESS_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondefines the Parts of the operation with all the information to become a fragment.booleaninthashCode()It creates a Criteria with a primary Criterion passed by parameter and a secondary Criterion which depends on the criterion passed by parameter.booleanisEmpty()If no criteria matched so far and there are no other criteria to check, then there are no criteria that matched with a given key-value pair. returntrueotherwise returnfalseThis method allows to add a decision criterion to the set of criteria defined by the current criteria.
It's very used to add a customized decision criterion, for example it's used in this way:
Criteria.static CriteriaCreates a new Criteria with a specific Criterion passed by parameters.Methods inherited from class overit.geocall.sql.code.criterion.Criterion
fieldDepiction
-
Field Details
-
START
Defines an empty Criteria used as starting point for your custom criteria. -
INSERT_ASSIGN
It's a predefinedCriteriaand it's used to define the content of the INSERT's SET clause.
This Criteria discard control fields and empty or null values.
For the others uses the EQUALS criterion. -
UPDATE_ASSIGN
It's a predefinedCriteriaand it's used to define the content of the UPDATE?s SET clause.
This Criteria discard control fields and reset empty set.
For the others uses the EQUALS criterion.
For example given this "AUSENAME,null" key-value pair, will be treated like "AUSENAME = NULL" in the SET clause. -
SEARCH_WEAK
It's a predefinedCriteriaand it's used to define the content of theSELECT'sWHEREclause.
ThisCriteriadiscard control fields andemptyornullvalues.Depending on the possible prefix of the field name, the corresponding
SQL clauseis created, supporting the following types:SqlOperator.IS_GREATER_THAN=><field> > <value>SqlOperator.IS_GREATER_THAN_OR_EQUAL_TO=><field> >= <value>SqlOperator.IS_LESS_THAN=><field> < <value>SqlOperator.IS_LESS_THAN_OR_EQUAL_TO=><field> <= <value>SqlOperator.IS_NULL=><field> IS NULLSqlOperator.IS_NOT_NULL=><field> IS NOT NULLSqlOperator.IS_NOT_EQUAL_TO=><field> != <value>SqlOperator.IS_LIKE=><field> like '<value>'SqlOperator.IS_IN=><field> IN (<values>)SqlOperator.IS_NOT_IN=><field> NOT IN (<values>)SqlOperator.IS_EQUAL_TO=><field> = <value>
Collection's values is treated with
INclause,Likestring is treated withLIKEclause and for the others uses theEQUALScriterion.
For example, given thisAUSEUSERNAME - admin%,AUSENAME - null,AUSEID_TUSE - [1,2,3],like:AUSESURNAME - 'Ross%',gte:AUSEBIRTHDATE - '2001-02-03'key-value pairs will be treated likeWHERE AUSEUSERNAME LIKE 'admin%' AND AUSEID_TUSE IN (1,2,3) AND AUSESURNAME LIKE 'Ross%' AND AUSEBIRTHDATE >= '2001-02-03'. -
SEARCH
It's a predefinedCriteriaand it's used to define the content of theSELECT'sWHEREclause.
ThisCriteriadiscard control fields andemptyornullvalues.Depending on the possible prefix of the field name, the corresponding
SQL clauseis created, supporting the following types:SqlOperator.IS_GREATER_THAN=><field> > <value>SqlOperator.IS_GREATER_THAN_OR_EQUAL_TO=><field> >= <value>SqlOperator.IS_LESS_THAN=><field> < <value>SqlOperator.IS_LESS_THAN_OR_EQUAL_TO=><field> <= <value>SqlOperator.IS_NULL=><field> IS NULLSqlOperator.IS_NOT_NULL=><field> IS NOT NULLSqlOperator.IS_NOT_EQUAL_TO=><field> != <value>SqlOperator.IS_LIKE=><field> like '<value>'SqlOperator.IS_IN=><field> IN (<values>)SqlOperator.IS_NOT_IN=><field> NOT IN (<values>)SqlOperator.IS_EQUAL_TO=><field> = <value>
Collection's values are treated with
INclause and for the others uses theEQUALScriterion.
For example, given thisAUSEUSERNAME - admin,AUSENAME - null,AUSEID_TUSE - [1,2,3],like:AUSESURNAME - 'Ross%',gte:AUSEBIRTHDATE - '2001-02-03'key-value pairs will be treated likeWHERE AUSEUSERNAME='admin' AND AUSEID_TUSE IN (1,2,3) AND AUSESURNAME LIKE 'Ross%' AND AUSEBIRTHDATE >= '2001-02-03'. -
SEARCH_STRONG
It's a predefinedCriteriaand it's used to define the content of theSELECT'sWHEREclause.
ThisCriteriadiscard control fields.Depending on the possible prefix of the field name, the corresponding
SQL clauseis created, supporting the following types:SqlOperator.IS_GREATER_THAN=><field> > <value>SqlOperator.IS_GREATER_THAN_OR_EQUAL_TO=><field> >= <value>SqlOperator.IS_LESS_THAN=><field> < <value>SqlOperator.IS_LESS_THAN_OR_EQUAL_TO=><field> <= <value>SqlOperator.IS_NULL=><field> IS NULLSqlOperator.IS_NOT_NULL=><field> IS NOT NULLSqlOperator.IS_NOT_EQUAL_TO=><field> != <value>SqlOperator.IS_LIKE=><field> like '<value>'SqlOperator.IS_IN=><field> IN (<values>)SqlOperator.IS_NOT_IN=><field> NOT IN (<values>)SqlOperator.IS_EQUAL_TO=><field> = <value>
Emptyornullvalues andemptycollections are treated withIS NULLclause.Collection's values is treated with
INclause and for the others uses theEQUALScriterion.
For example given thisAUSEUSERNAME - admin,AUSENAME - null,AUSEID_TUSE - [1,2,3],like:AUSESURNAME - 'Ross%',gte:AUSEBIRTHDATE - '2001-02-03',isnotnull:AUSEEMAILkey-value pairs will be treated likeWHERE AUSEUSERNAME='admin' AND AUSEID_TUSE IN (1,2,3) AND AUSENAME IS NULL AND AUSESURNAME LIKE 'Ross%' AND AUSEBIRTHDATE >= '2001-02-03' AND AUSEEMAIL IS NOT NULL. -
_onMatch
-
_otherwise
-
-
Constructor Details
-
Criteria
public Criteria()The Default constructor. -
Criteria
-
Criteria
The class's constructor. It defines a Criteria with a primary and secondary Criterion passed by parameters.- Parameters:
primary- The predefined Criterion used as primary.secondary- The predefined Criterion used as secondary.
-
-
Method Details
-
start
Creates a new Criteria with a specific Criterion passed by parameters.- Parameters:
c- The specific Criterion.- Returns:
- The new Criteria created with a specific Criterion passed by parameters.
-
isEmpty
public boolean isEmpty()If no criteria matched so far and there are no other criteria to check, then there are no criteria that matched with a given key-value pair. returntrueotherwise returnfalse- Returns:
trueif no criteria matched so far and there are no other criteria to check,falseotherwise.
-
ifNot
It creates a Criteria with a primary Criterion passed by parameter and a secondary Criterion which depends on the criterion passed by parameter.- Parameters:
criterion- The predefined Criterion used as primary.- Returns:
- A Criteria with a primary Criterion that is the criterion object passed by parameter and (as secondary criterion) null if criterion is empty or criterion itself if it's not empty.
-
otherwise
This method allows to add a decision criterion to the set of criteria defined by the current criteria.
It's very used to add a customized decision criterion, for example it's used in this way:
Criteria. START
.otherwise(new Decision(new Clause("@AUSEAGE >= 18")).forName("adult").forPattern(Boolean.class,true))
.otherwise(new Decision(new Clause("@AUSEAGE < 18")).forName("adult").forPattern(Boolean.class,false))
.otherwise(Criteria.SEARCH_WEAK);- Parameters:
other- The decision criterion to add.- Returns:
- A new Criteria with the decision criterion, passed by parameter, added.
-
define
Description copied from class:Criteriondefines the Parts of the operation with all the information to become a fragment.- Specified by:
definein classCriterion- Parameters:
name- the nome of the context fieldvalue- the current value of the context field- Returns:
- return null if the Criterion don't find an information, a Parts otherwise. Then Parts con also contain empty strings if the decision is to discard the name and the value
-
equals
-
hashCode
public int hashCode()
-