Interface TokenAction

All Known Implementing Classes:
GroupingTokenAction, TransformTokenAction, WrapTokenAction
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface TokenAction
Token action that is applied to a token rule match.
With a token action, the tokens of the match can be modified, transformed or removed.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull @Unmodifiable List<Token>
    apply(@NotNull TokenRuleMatch match)
    Applies this token action to the given token rule match.
    The action can modify, transform or remove the tokens of the match.
    static @NotNull TokenAction
    Creates a token action that does nothing.
    This action returns the matched tokens as they are.
    The resulting list is an immutable copy of the original list.
  • Method Details

    • identity

      @NotNull static @NotNull TokenAction identity()
      Creates a token action that does nothing.
      This action returns the matched tokens as they are.
      The resulting list is an immutable copy of the original list.
      Returns:
      The identity token action
      API Note:
      This method is equivalent to match -> List.copyOf(match.matchedTokens())
    • apply

      @NotNull @NotNull @Unmodifiable List<Token> apply(@NotNull @NotNull TokenRuleMatch match)
      Applies this token action to the given token rule match.
      The action can modify, transform or remove the tokens of the match.
      Parameters:
      match - The token rule match to apply the action to
      Returns:
      The resulting immutable list of tokens after applying the action
      Throws:
      NullPointerException - If the match is null