Interface Rule

  • All Superinterfaces:
    Comparable<Rule>
    All Known Implementing Classes:
    BasicRule

    public interface Rule
    extends Comparable<Rule>
    Abstraction for a rule that can be fired by a rules engine. Rules are registered in a namespace of rule of type Rules in which they must have a unique name.
    Author:
    Mahmoud Ben Hassine ([email protected])
    • Method Detail

      • getName

        default String getName()
        Getter for rule name.
        Returns:
        the rule name
      • getDescription

        default String getDescription()
        Getter for rule description.
        Returns:
        rule description
      • getPriority

        default int getPriority()
        Getter for rule priority.
        Returns:
        rule priority
      • evaluate

        boolean evaluate​(Facts facts)
        This method implements the rule's condition(s). Implementations should handle any runtime exception and return true/false accordingly
        Returns:
        true if the rule should be applied given the provided facts, false otherwise
      • execute

        void execute​(Facts facts)
              throws Exception
        This method implements the rule's action(s).
        Throws:
        Exception - thrown if an exception occurs when performing action(s)