Class CriteriaUtils

java.lang.Object
com.jbstrap.ui.utils.CriteriaUtils

public final class CriteriaUtils extends Object
Utilities for creating filter criteria.
Since:
4.0
Author:
JBStrap
  • Method Summary

    Modifier and Type
    Method
    Description
    static Criteria
    fromString(String criteriaStr)
    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),
    );

    static Criteria
    getCombinatedCriteria(Criteria firstCriteria, Criteria secondCriteria)
    Connects the filter criteria with an AND operator.
    static Criteria
    Negates the filter criterion (inverts the operator in the criterion).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • fromString

      public static Criteria fromString(String criteriaStr)
      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:
      Criteria object corresponding to the specified criterion text or null if the object cannot be created or null is specified
      Throws:
      NullPointerException - Thrown if the framework does not recognize the operator specified in the text criterion
      IllegalArgumentException - 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

      public static Criteria getCombinatedCriteria(Criteria firstCriteria, Criteria secondCriteria)
      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 also null.
      • If the first filter criterion is null, but the second filter criterion is not null, the return value is the second filter criterion.
      • If the first filter criterion is not null, but the second filter criterion is null, 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.
    • negateCriteria

      public static Criteria negateCriteria(Criteria criteria)
      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 null if the criterion is a complex one
      Throws:
      NullPointerException - Thrown if the specified filter criterion is null