Package com.jbstrap.ui.utils
Class CriteriaUtils
java.lang.Object
com.jbstrap.ui.utils.CriteriaUtils
Utilities for creating filter criteria.
- Since:
- 4.0
- Author:
- JBStrap
-
Method Summary
Modifier and TypeMethodDescriptionstatic CriteriafromString(String criteriaStr) Creates a filter criterion from the specified text.
Usage examples:
Criterion specified by text Java code corresponding to the criterionCriteria(id,EQUALS,25)new Criteria("id", OperatorType.EQUALS, 25);Criteria(AND,Criteria(id,GREATER_THAN,0),Citeria(id,LESS_THAN,10)new Criteria(OperatorType.AND, new Criteria[] {
new Criteria("id", OperatorType.GREATER_THAN, 0),
new Criteria("id", OperatorType.LESS_THAN, 10),
);static CriteriagetCombinatedCriteria(Criteria firstCriteria, Criteria secondCriteria) Connects the filter criteria with an AND operator.static CriterianegateCriteria(Criteria criteria) Negates the filter criterion (inverts the operator in the criterion).
-
Method Details
-
fromString
Creates a filter criterion from the specified text.
Usage examples:
Criterion specified by text Java code corresponding to the criterion Criteria(id,EQUALS,25)new Criteria("id", OperatorType.EQUALS, 25);Criteria(AND,Criteria(id,GREATER_THAN,0),Citeria(id,LESS_THAN,10)new Criteria(OperatorType.AND, new Criteria[] {
new Criteria("id", OperatorType.GREATER_THAN, 0),
new Criteria("id", OperatorType.LESS_THAN, 10),
);- Parameters:
criteriaStr- Criterion specified as text E.g. criterion read from the DataDescriptor or DataDescriptor column parameters- Returns:
Criteriaobject corresponding to the specified criterion text ornullif the object cannot be created ornullis specified- Throws:
NullPointerException- Thrown if the framework does not recognize the operator specified in the text criterionIllegalArgumentException- Thrown if the text criterion is not specified in the expected format or the text criterion contains a filter value that cannot be recognized
-
getCombinatedCriteria
Connects the filter criteria with an AND operator.- Parameters:
firstCriteria- The first criterion (usually the default filter criterion)secondCriteria- The second criterion (usually a simple criterion)- Returns:
- The compound criterion created as follows:
- If both filter criteria are
null, the return value is alsonull. - If the first filter criterion is
null, but the second filter criterion is notnull, the return value is the second filter criterion. - If the first filter criterion is not
null, but the second filter criterion isnull, the first criterion is returned. - If neither the first, nor the second filter criterion are null, the return value is a complex filter criterion containing the first and the second one, connected with an AND operator.
- If both filter criteria are
-
negateCriteria
Negates the filter criterion (inverts the operator in the criterion). The method only supports a simple filter criterion.- Parameters:
criteria- Simple filter criterion- Returns:
- Negated filter criterion or
nullif the criterion is a complex one - Throws:
NullPointerException- Thrown if the specified filter criterion isnull
-