Class Rule

  • All Implemented Interfaces:
    Serializable

    public class Rule
    extends MetadataItem
    A conditional set of actions to be executed in response to incoming events. Triggering of rules is guarded by a condition: the rule is only triggered if the associated condition (getCondition()) is satisfied. Once a rule triggers, a list of actions (getActions() can be performed as consequences. When rules trigger, a specific event is raised so that other parts of unomi can react to it accordingly. We can control how that event should be raised using isRaiseEventOnlyOnceForProfile() and isRaiseEventOnlyOnceForSession(). We could also specify a priority for our rule in case it needs to be executed before other ones when similar conditions match. This is accomplished using the getPriority() property.
    See Also:
    Serialized Form
    • Constructor Detail

      • Rule

        public Rule()
        Instantiates a new Rule.
      • Rule

        public Rule​(Metadata metadata)
        Instantiates a new Rule with the specified Metadata.
        Parameters:
        metadata - the metadata
    • Method Detail

      • getCondition

        public Condition getCondition()
        Retrieves the condition that, when satisfied, triggers the rule.
        Returns:
        the condition that, when satisfied, triggers the rule.
      • setCondition

        public void setCondition​(Condition condition)
        Sets the condition that, when satisfied, triggers the rule..
        Parameters:
        condition - the condition that, when satisfied, triggers the rule.
      • getActions

        public List<Action> getActions()
        Retrieves the actions to be performed when this rule triggers.
        Returns:
        the actions to be performed when this rule triggers
      • setActions

        public void setActions​(List<Action> actions)
        Sets the actions to be performed when this rule triggers.
        Parameters:
        actions - the actions to be performed when this rule triggers
      • getLinkedItems

        public List<String> getLinkedItems()
        Retrieves the linked items.
        Returns:
        the linked items
      • setLinkedItems

        public void setLinkedItems​(List<String> linkedItems)
        Sets the linked items.
        Parameters:
        linkedItems - the linked items
      • isRaiseEventOnlyOnceForProfile

        public boolean isRaiseEventOnlyOnceForProfile()
        Determines whether the event raised when the rule is triggered should only be raised once per Profile.
        Returns:
        true if the rule-triggered event should only be raised once per profile, false otherwise
      • isRaiseEventOnlyOnce

        public boolean isRaiseEventOnlyOnce()
        Determines whether the event raised when the rule is triggered should only be raised once
        Returns:
        true if the rule-triggered event should only be raised once per profile
      • setRaiseEventOnlyOnceForProfile

        public void setRaiseEventOnlyOnceForProfile​(boolean raiseEventOnlyOnceForProfile)
        Specifies whether the event raised when the rule is triggered should only be raised once per Profile.
        Parameters:
        raiseEventOnlyOnceForProfile - true if the rule-triggered event should only be raised once per profile, false otherwise
      • isRaiseEventOnlyOnceForSession

        public boolean isRaiseEventOnlyOnceForSession()
        Determines whether the event raised when the rule is triggered should only be raised once per Session.
        Returns:
        true if the rule-triggered event should only be raised once per session, false otherwise
      • setRaiseEventOnlyOnceForSession

        public void setRaiseEventOnlyOnceForSession​(boolean raiseEventOnlyOnceForSession)
        Specifies whether the event raised when the rule is triggered should only be raised once per Session.
        Parameters:
        raiseEventOnlyOnceForSession - true if the rule-triggered event should only be raised once per session, false otherwise
      • setRaiseEventOnlyOnce

        public void setRaiseEventOnlyOnce​(boolean raiseEventOnlyOnce)
        Specifies whether the event raised when the rule is triggered should only be raised once per Event.
        Parameters:
        raiseEventOnlyOnce - true if the rule-triggered event should only be raised once per event, false otherwise
      • getPriority

        public int getPriority()
        Retrieves the priority in case this Rule needs to be executed before other ones when similar conditions match.
        Returns:
        the priority
      • setPriority

        public void setPriority​(int priority)
        Sets the priority in case this Rule needs to be executed before other ones when similar conditions match.
        Parameters:
        priority - the priority