java.lang.Object
java.lang.Record
net.luis.utils.io.token.rule.TokenRuleMatch
- Record Components:
startIndex
- The start index of the matchendIndex
- The end index of the match (exclusive)matchedTokens
- The list of matched tokensmatchingTokenRule
- The matching token rule
public record TokenRuleMatch(int startIndex, int endIndex, @NotNull List<Token> matchedTokens, @NotNull TokenRule matchingTokenRule)
extends Record
A class that represents a match of a token rule.
It contains the start and end index of the match, the matched tokens, and the matching token rule.
It contains the start and end index of the match, the matched tokens, and the matching token rule.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
The field for theendIndex
record component.The field for thematchedTokens
record component.private final @NotNull TokenRule
The field for thematchingTokenRule
record component.private final int
The field for thestartIndex
record component. -
Constructor Summary
ConstructorsConstructorDescriptionTokenRuleMatch
(int startIndex, int endIndex, @NotNull List<Token> matchedTokens, @NotNull TokenRule matchingTokenRule) Constructs a new token rule match with the given start and end index, matched tokens, and matching token rule. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull TokenRuleMatch
empty
(int index) Creates an empty token rule match with the given index.
An empty token rule match has a start and end index of the given index, an empty list of matched tokens, and a matching token rule that always matches.
This is useful for terminating the token rule matching process without consuming any tokens.int
endIndex()
Returns the value of theendIndex
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.Returns the value of thematchedTokens
record component.@NotNull TokenRule
Returns the value of thematchingTokenRule
record component.int
Returns the value of thestartIndex
record component.final String
toString()
Returns a string representation of this record class.
-
Field Details
-
startIndex
private final int startIndexThe field for thestartIndex
record component. -
endIndex
private final int endIndexThe field for theendIndex
record component. -
matchedTokens
The field for thematchedTokens
record component. -
matchingTokenRule
The field for thematchingTokenRule
record component.
-
-
Constructor Details
-
TokenRuleMatch
public TokenRuleMatch(int startIndex, int endIndex, @NotNull @NotNull List<Token> matchedTokens, @NotNull @NotNull TokenRule matchingTokenRule) Constructs a new token rule match with the given start and end index, matched tokens, and matching token rule.- Parameters:
startIndex
- The start index of the matchendIndex
- The end index of the match (exclusive)matchedTokens
- The list of matched tokensmatchingTokenRule
- The matching token rule- Throws:
NullPointerException
- If the matched tokens or matching token rule are null
-
-
Method Details
-
empty
Creates an empty token rule match with the given index.
An empty token rule match has a start and end index of the given index, an empty list of matched tokens, and a matching token rule that always matches.
This is useful for terminating the token rule matching process without consuming any tokens.- Parameters:
index
- The index of the empty token rule match- Returns:
- An empty token rule match
- See Also:
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
startIndex
public int startIndex()Returns the value of thestartIndex
record component.- Returns:
- the value of the
startIndex
record component
-
endIndex
public int endIndex()Returns the value of theendIndex
record component.- Returns:
- the value of the
endIndex
record component
-
matchedTokens
Returns the value of thematchedTokens
record component.- Returns:
- the value of the
matchedTokens
record component
-
matchingTokenRule
Returns the value of thematchingTokenRule
record component.- Returns:
- the value of the
matchingTokenRule
record component
-