java.lang.Object
java.lang.Record
net.luis.utils.io.token.tokens.EscapedToken
- Record Components:
definition- The token definitionvalue- The string value of the tokenstartPosition- The start position of the tokenendPosition- The end position of the token
- All Implemented Interfaces:
Token
public record EscapedToken(@NotNull TokenDefinition definition, @NotNull String value, @NotNull TokenPosition startPosition, @NotNull TokenPosition endPosition)
extends Record
implements Token
Special token implementation for escaped tokens.
An escaped token is a token that starts with a backslash and has a length of 2.
An escaped token is a token that starts with a backslash and has a length of 2.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final @NotNull TokenDefinitionThe field for thedefinitionrecord component.private final @NotNull TokenPositionThe field for theendPositionrecord component.private final @NotNull TokenPositionThe field for thestartPositionrecord component.private final @NotNull StringThe field for thevaluerecord component. -
Constructor Summary
ConstructorsConstructorDescriptionEscapedToken(@NotNull TokenDefinition definition, @NotNull String value, @NotNull TokenPosition startPosition, @NotNull TokenPosition endPosition) Constructs a new escaped token for a string value. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull EscapedTokencreateUnpositioned(@NotNull TokenDefinition definition, @NotNull String value) Creates an unpositioned escaped token for the given token definition and value.@NotNull TokenDefinitionReturns the value of thedefinitionrecord component.@NotNull TokenPositionReturns the value of theendPositionrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@NotNull TokenPositionReturns the value of thestartPositionrecord component.@NotNull StringtoString()Returns a string representation of this record class.@NotNull Stringvalue()Returns the value of thevaluerecord component.
-
Field Details
-
definition
The field for thedefinitionrecord component. -
value
The field for thevaluerecord component. -
startPosition
The field for thestartPositionrecord component. -
endPosition
The field for theendPositionrecord component.
-
-
Constructor Details
-
EscapedToken
public EscapedToken(@NotNull @NotNull TokenDefinition definition, @NotNull @NotNull String value, @NotNull @NotNull TokenPosition startPosition, @NotNull @NotNull TokenPosition endPosition) Constructs a new escaped token for a string value.- Parameters:
definition- The token definitionvalue- The string value of the tokenstartPosition- The start position of the tokenendPosition- The end position of the token- Throws:
NullPointerException- If any of the parameters are nullIllegalArgumentException- If the token value does not have a length of 2, does not start with a backslash or does not match the token definition. If the start and end positions are positioned, the distance between them must be equal to the length of the token value minus 1 (inclusive).
-
-
Method Details
-
createUnpositioned
@NotNull public static @NotNull EscapedToken createUnpositioned(@NotNull @NotNull TokenDefinition definition, @NotNull @NotNull String value) Creates an unpositioned escaped token for the given token definition and value.- Parameters:
definition- The token definitionvalue- The string value of the token- Returns:
- The unpositioned escaped token
- Throws:
NullPointerException- If the token definition or the token value is nullIllegalArgumentException- If the token value does not have a length of 2, does not start with a backslash or does not match the token definition
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
definition
Returns the value of thedefinitionrecord component.- Specified by:
definitionin interfaceToken- Returns:
- the value of the
definitionrecord component
-
value
Returns the value of thevaluerecord component. -
startPosition
Returns the value of thestartPositionrecord component.- Specified by:
startPositionin interfaceToken- Returns:
- the value of the
startPositionrecord component
-
endPosition
Returns the value of theendPositionrecord component.- Specified by:
endPositionin interfaceToken- Returns:
- the value of the
endPositionrecord component
-