Package org.evrete

Class AbstractRule

java.lang.Object
org.evrete.AbstractRule
All Implemented Interfaces:
Environment, FluentEnvironment<Rule>, Named, NamedType.Resolver, Rule

public abstract class AbstractRule extends Object implements Rule
Abstract base class that implements the Rule interface. It provides basic functionality common to all implementations of the Rule interface.
  • Field Details

  • Constructor Details

    • AbstractRule

      protected AbstractRule(String name)
    • AbstractRule

      protected AbstractRule(AbstractRule other, String ruleName, int salience)
  • Method Details

    • getRhs

      public Consumer<RhsContext> getRhs()
      Description copied from interface: Rule
      Gets the RHS (Right Hand Side) logic as a Consumer.
      Specified by:
      getRhs in interface Rule
      Returns:
      the RHS logic consumer.
    • setRhs

      public void setRhs(Consumer<RhsContext> rhs)
      Description copied from interface: Rule
      Sets the RHS logic using a Consumer. Can be null.
      Specified by:
      setRhs in interface Rule
      Parameters:
      rhs - the RHS logic consumer.
    • setRhs

      public void setRhs(String literalRhs)
      Description copied from interface: Rule
      Sets the RHS logic using a literal string. The literal will be compiled and converted into a Consumer.
      Specified by:
      setRhs in interface Rule
      Parameters:
      literalRhs - the string representation of RHS logic.
    • getPropertyNames

      public Collection<String> getPropertyNames()
      Description copied from interface: Environment
      Retrieves a collection of all property names in the environment.
      Specified by:
      getPropertyNames in interface Environment
      Returns:
      A collection of strings representing all property names in the environment.
    • getLiteralRhs

      public String getLiteralRhs()
    • getSalience

      public final int getSalience()
      Description copied from interface: Rule
      Retrieves the rule's salience.
      Specified by:
      getSalience in interface Rule
      Returns:
      the salience value.
    • setSalience

      public void setSalience(int salience)
      Description copied from interface: Rule
      Sets the rule's salience.
      Specified by:
      setSalience in interface Rule
      Parameters:
      salience - the salience value to set.
    • set

      public Rule set(String property, Object value)
      Description copied from interface: FluentEnvironment
      Sets the specified property to the given value.
      Specified by:
      set in interface Environment
      Specified by:
      set in interface FluentEnvironment<Rule>
      Parameters:
      property - the name of the property to set; should not be null.
      value - the new value for the property; the actual type is determined by the implementation and the property being set.
      Returns:
      the current instance of X to allow for method chaining.
    • get

      public final <T> T get(String property)
      Description copied from interface: Environment
      Retrieves the value of a property by its name.
      Specified by:
      get in interface Environment
      Type Parameters:
      T - The expected type of the property value.
      Parameters:
      property - The name of the property to retrieve.
      Returns:
      The value of the property as type T, or null if it does not exist.
    • getName

      public final String getName()
      Specified by:
      getName in interface Named
    • setName

      public void setName(String name)
      Description copied from interface: Rule
      Sets a new name for the rule.
      Specified by:
      setName in interface Rule
      Parameters:
      name - the new name to give to the rule.
    • chainRhs

      public void chainRhs(Consumer<RhsContext> consumer)
      Description copied from interface: Rule
      Chains a consumer to the current RHS logic. The provided consumer is executed after the current RHS.
      Specified by:
      chainRhs in interface Rule
      Parameters:
      consumer - the consumer to chain.