Class SimpleToken
java.lang.Object
org.antlr.v4.runtime.CommonToken
com.puppycrawl.tools.checkstyle.grammar.SimpleToken
- All Implemented Interfaces:
Serializable, org.antlr.v4.runtime.Token, org.antlr.v4.runtime.WritableToken
public final class SimpleToken
extends org.antlr.v4.runtime.CommonToken
A simple wrapper for ANTLR
Token that provides a proper equals(Object)
and hashCode() implementation based on the token's type and text.
This is useful because ANTLR's default CommonToken does not override
equals, It compares references.
- See Also:
-
Field Summary
FieldsFields inherited from class org.antlr.v4.runtime.CommonToken
channel, charPositionInLine, EMPTY_SOURCE, index, line, source, start, stop, text, typeFields inherited from interface org.antlr.v4.runtime.Token
DEFAULT_CHANNEL, EOF, EPSILON, HIDDEN_CHANNEL, INVALID_TYPE, MIN_USER_CHANNEL_VALUE, MIN_USER_TOKEN_TYPE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSimpleToken(org.antlr.v4.runtime.Token token) Constructs a new instance from an existing ANTLRToken. -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic SimpleTokenfrom(org.antlr.v4.runtime.Token token) Creates a new instance from an existing ANTLRToken.inthashCode()Methods inherited from class org.antlr.v4.runtime.CommonToken
getChannel, getCharPositionInLine, getInputStream, getLine, getStartIndex, getStopIndex, getText, getTokenIndex, getTokenSource, getType, setChannel, setCharPositionInLine, setLine, setStartIndex, setStopIndex, setText, setTokenIndex, setType, toString, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
SimpleToken
private SimpleToken(org.antlr.v4.runtime.Token token) Constructs a new instance from an existing ANTLRToken.- Parameters:
token- the ANTLR token to wrap
-
-
Method Details
-
from
Creates a new instance from an existing ANTLRToken.- Parameters:
token- the ANTLR token to wrap- Returns:
- a new instance of SimpleToken wrapping the provided token
-
equals
-
hashCode
-