Record Class Criterion

java.lang.Object
java.lang.Record
com.axelor.ai.tool.system.Criterion
Record Components:
fieldName - the field to match, a dotted path for a field of a related model
operator - what to test, or how to join criteria
value - what to match against; the lower bound of a between
value2 - the upper bound of a between or notBetween
criteria - the conditions an and, or or not joins

public record Criterion(String fieldName, String operator, Object value, Object value2, List<Criterion> criteria) extends Record
One filter condition, or a group of them.

A leaf names a field, an operator and what to match against. A compound names one of and, or or not and the conditions it joins, nested as deeply as the caller needs.

It is a record rather than a free-form map so that the shape a tool accepts is stated once, in the type that reads it: what the model is told it may send is generated from this, and a key that is not here is refused rather than quietly ignored.

  • Constructor Details

    • Criterion

      public Criterion(String fieldName, String operator, Object value, Object value2, List<Criterion> criteria)
      Creates an instance of a Criterion record class.
      Parameters:
      fieldName - the value for the fieldName record component
      operator - the value for the operator record component
      value - the value for the value record component
      value2 - the value for the value2 record component
      criteria - the value for the criteria record component
  • Method Details

    • toMap

      public Map<String,Object> toMap()
      The same condition as the map the query layer parses.

      Criteria reads a map, so the typed shape is turned back into one at the edge rather than the tool keeping a map around to avoid it. Only what was given is included: a key present with a null value is not the same to that parser as a key left out.

    • withFieldName

      public Criterion withFieldName(String name)
      The same condition with a different field name, for a tool that rewrites paths.
    • withCriteria

      public Criterion withCriteria(List<Criterion> nested)
      The same condition with different nested ones.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • fieldName

      public String fieldName()
      Returns the value of the fieldName record component.
      Returns:
      the value of the fieldName record component
    • operator

      public String operator()
      Returns the value of the operator record component.
      Returns:
      the value of the operator record component
    • value

      public Object value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component
    • value2

      public Object value2()
      Returns the value of the value2 record component.
      Returns:
      the value of the value2 record component
    • criteria

      public List<Criterion> criteria()
      Returns the value of the criteria record component.
      Returns:
      the value of the criteria record component