Class UniLeftHandSide<A>

  • Type Parameters:
    A - generic type of the resulting variable

    public final class UniLeftHandSide<A>
    extends Object
    Represents the left-hand side of a Drools rule, the result of which is a single variable. The simplest variant of such rule, with no filters or groupBys applied, would look like this in equivalent DRL:
     
      rule "Simplest univariate rule"
      when
          $a: Something()
      then
          // Do something with the $a variable.
      end
     
     
    Left-hand side is that part of the rule between the "when" and "then" keywords. The part between the "then" and "end" keywords is called the consequence of the rule, and this class does not represent it. It can be created by calling andTerminate(). There are also more complex variants of rules that still result in just one variable:
     
      rule "Complex univariate rule"
      when
          $accumulateResult: Collection() from accumulate(
              ...
          )
          $a: Object() from $accumulateResult
          exists Something()
      then
          // Do something with the $a variable.
      end
     
     
    To create the simplest possible variant, call UniLeftHandSide(Class, DroolsVariableFactory). Further specializations can be introduced by calling builder methods such as andFilter(Predicate). These builder methods will always return a new instance of AbstractLeftHandSide, as these are immutable. Some builder methods, such as andJoin(UniLeftHandSide, BiJoiner), will return an instance of BiLeftHandSide (TriLeftHandSide, ...), as that particular operation will increase the cardinality of the parent constraint stream.