Class TokenSequence

java.lang.Object
li.selman.jpbe.dsl.token.TokenSequence
All Implemented Interfaces:
Iterable<Token>, DslElement

public final class TokenSequence extends Object implements DslElement, Iterable<Token>
Merges a list of tokens together to a new combined token. The whole TokenSequence must match.

If no tokens are past, the sequence matches everything

See Also:
  • Method Details

    • of

      public static TokenSequence of(Token... tokens)
    • of

      public static TokenSequence of(List<Token> tokens)
    • getTokens

      public List<Token> getTokens()
    • getNumberOfTokens

      public int getNumberOfTokens()
    • isEmpty

      public boolean isEmpty()
    • getLastToken

      public Token getLastToken()
      Returns:
      the last token or null if the sequence is empty
    • getMergedPattern

      public Pattern getMergedPattern()
    • union

      public TokenSequence union(TokenSequence other)
    • sequenceLength

      public int sequenceLength()
      Returns:
      the size of tokens
    • getDslWeight

      public int getDslWeight()
      Note that the size of the DslElement and the size of tokens can differ! Do not use this method to get the number of tokens in the sequence.
      Specified by:
      getDslWeight in interface DslElement
      Returns:
      the weight of the token TokenSequence
    • iterator

      public Iterator<Token> iterator()
      Specified by:
      iterator in interface Iterable<Token>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object