java.lang.Object
org.openhab.core.automation.module.script.rulesupport.shared.simple.SimpleRule
All Implemented Interfaces:
SimpleRuleActionHandler, Rule, Identifiable<String>

@NonNullByDefault public abstract class SimpleRule extends Object implements Rule, SimpleRuleActionHandler
convenience Rule class with an action handler. This allows to define Rules which have an execution block.
Author:
Simon Merschjohann - Initial contribution, Kai Kreuzer - made it implement Rule
  • Field Details

    • triggers

      @NonNullByDefault({}) protected List<Trigger> triggers
    • conditions

      @NonNullByDefault({}) protected List<Condition> conditions
    • actions

      @NonNullByDefault({}) protected List<Action> actions
    • configuration

      @NonNullByDefault({}) protected Configuration configuration
    • configDescriptions

      @NonNullByDefault({}) protected List<ConfigDescriptionParameter> configDescriptions
    • templateUID

      protected @Nullable String templateUID
    • uid

      @NonNullByDefault({}) protected String uid
    • name

      protected @Nullable String name
    • tags

      @NonNullByDefault({}) protected Set<String> tags
    • visibility

      @NonNullByDefault({}) protected Visibility visibility
    • description

      protected @Nullable String description
    • status

      protected transient volatile RuleStatusInfo status
  • Constructor Details

    • SimpleRule

      public SimpleRule()
  • Method Details

    • getUID

      public String getUID()
      Description copied from interface: Rule
      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>
      Specified by:
      getUID in interface Rule
      Returns:
      an identifier of this Rule. Can't be null.
    • getTemplateUID

      public @Nullable String getTemplateUID()
      Description copied from interface: Rule
      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.
      Specified by:
      getTemplateUID in interface Rule
      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.
    • setTemplateUID

      public void setTemplateUID(@Nullable String templateUID)
      This method is used to specify the RuleTemplate identifier of the template that will be used to by the RuleRegistry to resolve the Rule: to validate the Rule's configuration, as well as to create and configure the Rule's modules.
    • getName

      public @Nullable String getName()
      Description copied from interface: Rule
      This method is used to obtain the Rule's human-readable name.
      Specified by:
      getName in interface Rule
      Returns:
      the Rule's human-readable name, or null.
    • setName

      public void setName(@Nullable String ruleName)
      This method is used to specify the Rule's human-readable name.
      Parameters:
      ruleName - the Rule's human-readable name, or null.
    • getTags

      public Set<String> getTags()
      Description copied from interface: Rule
      This method is used to obtain the Rule's assigned tags.
      Specified by:
      getTags in interface Rule
      Returns:
      the Rule's assigned tags.
    • setTags

      public void setTags(@Nullable Set<String> ruleTags)
      This method is used to specify the Rule's assigned tags.
      Parameters:
      ruleTags - the Rule's assigned tags.
    • getDescription

      public @Nullable String getDescription()
      Description copied from interface: Rule
      This method is used to obtain the human-readable description of the purpose and consequences of the Rule's execution.
      Specified by:
      getDescription in interface Rule
      Returns:
      the Rule's human-readable description, or null.
    • setDescription

      public void setDescription(@Nullable String ruleDescription)
      This method is used to specify human-readable description of the purpose and consequences of the Rule's execution.
      Parameters:
      ruleDescription - the Rule's human-readable description, or null.
    • getVisibility

      public Visibility getVisibility()
      Description copied from interface: Rule
      This method is used to obtain the Rule's Visibility.
      Specified by:
      getVisibility in interface Rule
      Returns:
      the Rule's Visibility value.
    • setVisibility

      public void setVisibility(@Nullable Visibility visibility)
      This method is used to specify the Rule's Visibility.
      Parameters:
      visibility - the Rule's Visibility value.
    • getConfiguration

      public Configuration getConfiguration()
      Description copied from interface: Rule
      This method is used to obtain the Rule's Configuration.
      Specified by:
      getConfiguration in interface Rule
      Returns:
      current configuration values, or an empty Configuration.
    • setConfiguration

      public void setConfiguration(@Nullable Configuration ruleConfiguration)
      This method is used to specify the Rule's Configuration.
      Parameters:
      ruleConfiguration - the new configuration values.
    • getConfigurationDescriptions

      public List<ConfigDescriptionParameter> getConfigurationDescriptions()
      Description copied from interface: Rule
      This method is used to obtain the List with ConfigDescriptionParameters defining meta info for configuration properties of the Rule.
      Specified by:
      getConfigurationDescriptions in interface Rule
      Returns:
      a List of ConfigDescriptionParameters.
    • setConfigurationDescriptions

      public void setConfigurationDescriptions(@Nullable List<ConfigDescriptionParameter> configDescriptions)
      This method is used to describe with ConfigDescriptionParameters the meta info for configuration properties of the Rule.
    • getConditions

      public List<Condition> getConditions()
      Description copied from interface: Rule
      This method is used to get the conditions participating in Rule.
      Specified by:
      getConditions in interface Rule
      Returns:
      a list with the conditions that belong to this Rule.
    • setConditions

      public void setConditions(@Nullable List<Condition> conditions)
      This method is used to specify the conditions participating in Rule.
      Parameters:
      conditions - a list with the conditions that should belong to this Rule.
    • getActions

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

      public List<Trigger> getTriggers()
      Description copied from interface: Rule
      This method is used to get the triggers participating in Rule.
      Specified by:
      getTriggers in interface Rule
      Returns:
      a list with the triggers that belong to this Rule.
    • setActions

      public void setActions(@Nullable List<Action> actions)
      This method is used to specify the actions participating in Rule
      Parameters:
      actions - a list with the actions that should belong to this Rule.
    • setTriggers

      public void setTriggers(@Nullable List<Trigger> triggers)
      This method is used to specify the triggers participating in Rule
      Parameters:
      triggers - a list with the triggers that should belong to this Rule.
    • getModules

      public List<Module> getModules()
      Description copied from interface: Rule
      Obtains the modules of the Rule.
      Specified by:
      getModules in interface Rule
      Returns:
      the modules of the Rule or empty list if the Rule has no modules.
    • getModules

      public <T extends Module> List<T> getModules(@Nullable Class<T> moduleClazz)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object