Class FastRule

java.lang.Object
org.jeasy.rules.core.FastRule
All Implemented Interfaces:
Comparable<Rule>, Rule

public abstract class FastRule extends Object implements Rule
Basic rule implementation class that provides common methods.

You can extend this class and override when(Facts) and then(Facts) to provide rule conditions and actions logic. This is very similar to BasicRule

Author:
Mahmoud Ben Hassine ([email protected])
  • Field Details

    • name

      protected String name
      Rule name.
    • description

      protected String description
      Rule description.
    • priority

      protected int priority
      Rule priority.
  • Constructor Details

    • FastRule

      protected FastRule(String name, String description, int priority)
    • FastRule

      protected FastRule(String name)
  • Method Details

    • when

      protected abstract boolean when(Facts facts)
    • then

      protected abstract void then(Facts facts)
    • evaluate

      public final boolean evaluate(Facts facts)
      Description copied from interface: Rule
      This method implements the rule's condition(s). Implementations should handle any runtime exception and return true/false accordingly
      Specified by:
      evaluate in interface Rule
      Returns:
      true if the rule should be applied given the provided facts, false otherwise
    • execute

      public final void execute(Facts facts) throws Exception
      Description copied from interface: Rule
      This method implements the rule's action(s).
      Specified by:
      execute in interface Rule
      Throws:
      Exception - thrown if an exception occurs when performing action(s)
    • getName

      public String getName()
      Description copied from interface: Rule
      Getter for rule name.
      Specified by:
      getName in interface Rule
      Returns:
      the rule name
    • getDescription

      public String getDescription()
      Description copied from interface: Rule
      Getter for rule description.
      Specified by:
      getDescription in interface Rule
      Returns:
      rule description
    • getPriority

      public int getPriority()
      Description copied from interface: Rule
      Getter for rule priority.
      Specified by:
      getPriority in interface Rule
      Returns:
      rule priority