Package io.ran.token
Class Token
java.lang.Object
io.ran.token.Token
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Token
Parses a camelCase string into a token.boolean
static Token
Create a token from a string.getParts()
A list of the parts of this token.int
hashCode()
static Token
Human_readable
(String tokenString) Parses a human-readable string into a token.static Token
javaMethod
(String tokenString) static Token
Create a token consisting of a single literal string.static Token
Deprecated.static Token
Deprecated.You should probably useget(String)
, or one of the specific format methods.static Token
PascalCase
(String tokenString) Parses a PascalCase string into a token.static Token
snake_case
(String tokenString) Parses a snake_case string into a token.int
toString()
-
Field Details
-
ILLEGAL_CHARACTERS
- See Also:
-
-
Method Details
-
get
Create a token from a string. This will attempt to guess the format of the string and return the appropriate token type- Parameters:
anyFormat
- a string containing a token in any format- Returns:
- a token in the appropriate format, if the format is not recognized, it will return a camelCase token
-
of
Deprecated.You should probably useget(String)
, or one of the specific format methods. If you know what you're doing, suppress the warningCreate a token consisting exactly of the parts specified. -
of
Deprecated.You should probably useget(String)
, or one of the specific format methods. If you know what you're doing, suppress the warningCreate a token consisting exactly of the parts specified. -
literal
Create a token consisting of a single literal string.This is useful for when you want to create a token from a string that is not in any of the standard formats, or when you need to access something with a token but the underlying representation is not using proper tokens.
- Parameters:
literal
- the literal string to use as the token- Returns:
- a token consisting of a single literal string
- Throws:
InvalidTokenException
- if the literal is null
-
PascalCase
Parses a PascalCase string into a token. This will throw an exception if the string is not in PascalCase format- Parameters:
tokenString
- a string in PascalCase format- Returns:
- a token representing the PascalCase string
- Throws:
InvalidTokenException
- if the string is not in PascalCase format
-
camelCase
Parses a camelCase string into a token. This will throw an exception if the string is not in camelCase format- Parameters:
tokenString
- a string in camelCase format- Returns:
- a token representing the camelCase string
- Throws:
InvalidTokenException
- if the string is not in camelCase format
-
snake_case
Parses a snake_case string into a token. This will throw an exception if the string is not in snake_case format- Parameters:
tokenString
- a string in snake_case format- Returns:
- a token representing the snake_case string
- Throws:
InvalidTokenException
- if the string is not in snake_case format
-
Human_readable
Parses a human-readable string into a token. This will throw an exception if the string is not in human-readable formatA human-readable string is a string consisting of words separated by whitespace characters.
- Parameters:
tokenString
- a string in human-readable format- Returns:
- a token representing the human-readable string
- Throws:
InvalidTokenException
- if the string is not in human-readable format
-
javaMethod
-
toString
-
stringLength
public int stringLength()- Returns:
- the total number of characters in all the parts of this token
-
getParts
A list of the parts of this token.Each part is a string, and the list is in the order that the parts appear in the token.
- Returns:
- the parts of this token
-
PascalCase
- Returns:
- a string in
PascalCase
format representing this token
-
camelCase
- Returns:
- a string in
camelCase
format representing this token
-
snake_case
- Returns:
- a string in
snake_case
format representing this token
-
Human_readable
- Returns:
- a string in
Human readable
format representing this token
-
javaMethod
-
equals
-
hashCode
public int hashCode()
-
get(String)
, or one of the specific format methods.