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 TokenDefinition
The field for thedefinition
record component.private final @NotNull TokenPosition
The field for theendPosition
record component.private final @NotNull TokenPosition
The field for thestartPosition
record component.private final @NotNull String
The field for thevalue
record 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 EscapedToken
createUnpositioned
(@NotNull TokenDefinition definition, @NotNull String value) Creates an unpositioned escaped token for the given token definition and value.@NotNull TokenDefinition
Returns the value of thedefinition
record component.@NotNull TokenPosition
Returns the value of theendPosition
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.@NotNull TokenPosition
Returns the value of thestartPosition
record component.@NotNull String
toString()
Returns a string representation of this record class.@NotNull String
value()
Returns the value of thevalue
record component.
-
Field Details
-
definition
The field for thedefinition
record component. -
value
The field for thevalue
record component. -
startPosition
The field for thestartPosition
record component. -
endPosition
The field for theendPosition
record 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 thedefinition
record component.- Specified by:
definition
in interfaceToken
- Returns:
- the value of the
definition
record component
-
value
Returns the value of thevalue
record component. -
startPosition
Returns the value of thestartPosition
record component.- Specified by:
startPosition
in interfaceToken
- Returns:
- the value of the
startPosition
record component
-
endPosition
Returns the value of theendPosition
record component.- Specified by:
endPosition
in interfaceToken
- Returns:
- the value of the
endPosition
record component
-