Class BasicRule

    • Field Detail

      • name

        protected String name
        Rule name.
      • description

        protected String description
        Rule description.
      • priority

        protected int priority
        Rule priority.
    • Constructor Detail

      • BasicRule

        @Deprecated(since="1.0.1",
                    forRemoval=true)
        protected BasicRule()
        Deprecated, for removal: This API element is subject to removal in a future version.
        To avoid hardcoded rule name, Rule name should be unique
        Create a new BasicRule. Please use other constructor method as name parameter uniquely identifies a rule
      • BasicRule

        protected BasicRule​(String name)
        Create a new BasicRule.
        Parameters:
        name - rule name
      • BasicRule

        protected BasicRule​(String name,
                            String description)
        Create a new BasicRule.
        Parameters:
        name - rule name
        description - rule description
      • BasicRule

        protected BasicRule​(String name,
                            String description,
                            int priority)
        Create a new BasicRule.
        Parameters:
        name - rule name
        description - rule description
        priority - rule priority
    • Method Detail

      • evaluate

        public boolean evaluate​(Facts facts)
        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 void execute​(Facts facts)
                     throws Exception
        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
      • setDescription

        public void setDescription​(String description)
      • getPriority

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

        public void setPriority​(int priority)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object