Class CriteriaCheck

java.lang.Object
com.axelor.ai.tool.system.CriteriaCheck

public final class CriteriaCheck extends Object
Checks a criteria object before a tool builds a query out of it.

Every way a criterion can be wrong ends the same way without this: the query runs, matches nothing or everything, and answers. A filter that quietly stopped filtering is the one wrong answer a caller cannot notice, so the shape, the names and the values are settled here, once, and what builds the query afterwards can assume they hold.

It is shared rather than written per tool because each tool that takes criteria would otherwise re-derive the same rules, and the ones that got them wrong got them wrong quietly. What differs between tools is only which operators they can express, which each passes in.

  • Method Details

    • validate

      public static void validate(Criterion criteria, String modelName, CriteriaCheck.Fields fields, Set<Operator> supported)
      Refuses criteria this tool cannot answer truthfully.
      Parameters:
      modelName - the model as the caller named it, for what is reported back
      fields - what the model's fields are and what they accept
      supported - the leaf operators this tool can express
      Throws:
      IllegalArgumentException - naming what is wrong and what would be right
    • operatorOf

      public static Operator operatorOf(Criterion criterion)
      The operator a criterion names, whichever of its two spellings was used.

      = and equals are one operator, as are and and AND: Operator accepts both, so anything reading criteria has to accept both too, or it refuses a spelling the rest of the platform takes.