Class TriggerSequence

  • Direct Known Subclasses:
    KeySequence

    public abstract class TriggerSequence
    extends Object

    A sequence of one or more triggers. None of these triggers may be null.

    Since:
    3.1
    • Field Detail

      • hashCode

        protected transient int hashCode
        The hash code for this object. This value is computed lazily, and marked as invalid when one of the values on which it is based changes. This values is HASH_CODE_NOT_COMPUTED iff the hash code has not yet been computed.
      • triggers

        protected final Trigger[] triggers
        The list of trigger in this sequence. This value is never null, and never contains null elements.
    • Constructor Detail

      • TriggerSequence

        public TriggerSequence​(Trigger[] triggers)
        Constructs a new instance of TriggerSequence.
        Parameters:
        triggers - The triggers contained within this sequence; must not be null or contain null elements. May be empty.
    • Method Detail

      • endsWith

        public final boolean endsWith​(TriggerSequence triggerSequence,
                                      boolean equals)
        Returns whether or not this key sequence ends with the given key sequence.
        Parameters:
        triggerSequence - a trigger sequence. Must not be null.
        equals - whether or not an identical trigger sequence should be considered as a possible match.
        Returns:
        true, iff the given trigger sequence ends with this trigger sequence.
      • equals

        public final boolean equals​(Object object)
        Overrides:
        equals in class Object
      • format

        public abstract String format()
        Formats this trigger sequence into the current default look.
        Returns:
        A string representation for this trigger sequence using the default look; never null.
      • getPrefixes

        public abstract TriggerSequence[] getPrefixes()

        Returns a list of prefixes for the current sequence. A prefix is any leading subsequence in a TriggerSequence. A prefix is also an instance of TriggerSequence.

        For example, consider a trigger sequence that consists of four triggers: A, B, C and D. The prefixes would be "", "A", "A B", and "A B C". The list of prefixes must always be the same as the size of the trigger list.

        Returns:
        The array of possible prefixes for this sequence. This array must not be null, but may be empty. It must only contains instances of TriggerSequence.
      • getTriggers

        public final Trigger[] getTriggers()
        Returns the list of triggers.
        Returns:
        The triggers; never null and guaranteed to only contain instances of Trigger.
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object
      • isEmpty

        public final boolean isEmpty()
        Returns whether or not this trigger sequence is empty.
        Returns:
        true, iff the trigger sequence is empty.
      • startsWith

        public final boolean startsWith​(TriggerSequence triggerSequence,
                                        boolean equals)
        Returns whether or not this trigger sequence starts with the given trigger sequence.
        Parameters:
        triggerSequence - a trigger sequence. Must not be null.
        equals - whether or not an identical trigger sequence should be considered as a possible match.
        Returns:
        true, iff the given trigger sequence starts with this key sequence.