Interface Rule

All Superinterfaces:
Identifiable<String>
All Known Implementing Classes:
SimpleRule

@NonNullByDefault public interface Rule extends Identifiable<String>
An automation Rule is built from Modules and consists of three parts:
  • Triggers: a list of Trigger modules. Each Trigger from this list can start the evaluation of the Rule. A Rule with an empty list of Triggers can only be triggered through the RuleManager.runNow(String, boolean, java.util.Map) method, or directly executed with the RuleManager.runNow(String) method.
  • Conditions: a list of Condition modules. When a Rule is triggered, the evaluation of the Rule Conditions will determine if the Rule will be executed. A Rule will be executed only when all it's Conditions are satisfied. If the Conditions list is empty, the Rule is considered satisfied.
  • Actions: a list of Action modules. These modules determine the actions that will be performed when a Rule is executed.
Additionally, Rules can have tags - non-hierarchical keywords or terms for describing them. They can help the user to classify or label the Rules, and to filter and search them.
Author:
Kai Kreuzer - Initial contribution
  • Method Details

    • getUID

      String getUID()
      This method is used to obtain the identifier of the Rule. It can be specified by the Rule's creator, or randomly generated.
      Specified by:
      getUID in interface Identifiable<String>
      Returns:
      an identifier of this Rule. Can't be null.
    • getTemplateUID

      @Nullable String getTemplateUID()
      This method is used to obtain the RuleTemplate identifier of the template the Rule was created from. It will be used by the RuleRegistry to resolve the Rule: to validate the Rule's configuration, as well as to create and configure the Rule's modules. If a Rule has not been created from a template, or has been successfully resolved by the RuleRegistry, this method will return null.
      Returns:
      the identifier of the Rule's RuleTemplate, or null if the Rule has not been created from a template, or has been successfully resolved by the RuleRegistry.
    • getName

      @Nullable String getName()
      This method is used to obtain the Rule's human-readable name.
      Returns:
      the Rule's human-readable name, or null.
    • getTags

      Set<String> getTags()
      This method is used to obtain the Rule's assigned tags.
      Returns:
      the Rule's assigned tags.
    • getDescription

      @Nullable String getDescription()
      This method is used to obtain the human-readable description of the purpose and consequences of the Rule's execution.
      Returns:
      the Rule's human-readable description, or null.
    • getVisibility

      Visibility getVisibility()
      This method is used to obtain the Rule's Visibility.
      Returns:
      the Rule's Visibility value.
    • getConfiguration

      Configuration getConfiguration()
      This method is used to obtain the Rule's Configuration.
      Returns:
      current configuration values, or an empty Configuration.
    • getConfigurationDescriptions

      List<ConfigDescriptionParameter> getConfigurationDescriptions()
      This method is used to obtain the List with ConfigDescriptionParameters defining meta info for configuration properties of the Rule.
      Returns:
      a List of ConfigDescriptionParameters.
    • getConditions

      List<Condition> getConditions()
      This method is used to get the conditions participating in Rule.
      Returns:
      a list with the conditions that belong to this Rule.
    • getActions

      List<Action> getActions()
      This method is used to get the actions participating in Rule.
      Returns:
      a list with the actions that belong to this Rule.
    • getTriggers

      List<Trigger> getTriggers()
      This method is used to get the triggers participating in Rule.
      Returns:
      a list with the triggers that belong to this Rule.
    • getModules

      List<Module> getModules()
      Obtains the modules of the Rule.
      Returns:
      the modules of the Rule or empty list if the Rule has no modules.
    • getModule

      default @Nullable Module getModule(String moduleId)
      This method is used to get a Module participating in Rule
      Parameters:
      moduleId - specifies the id of a module belonging to this Rule.
      Returns:
      module with specified id or null if it does not belong to this Rule.