Package io.ran.token
Class Token
java.lang.Object
io.ran.token.Token
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic TokenParses a camelCase string into a token.booleanstatic TokenCreate a token from a string.getParts()A list of the parts of this token.inthashCode()static TokenHuman_readable(String tokenString) Parses a human-readable string into a token.static TokenjavaMethod(String tokenString) static TokenCreate a token consisting of a single literal string.static TokenDeprecated.static TokenDeprecated.You should probably useget(String), or one of the specific format methods.static TokenPascalCase(String tokenString) Parses a PascalCase string into a token.static Tokensnake_case(String tokenString) Parses a snake_case string into a token.inttoString()
-
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
PascalCaseformat representing this token
-
camelCase
- Returns:
- a string in
camelCaseformat representing this token
-
snake_case
- Returns:
- a string in
snake_caseformat representing this token
-
Human_readable
- Returns:
- a string in
Human readableformat representing this token
-
javaMethod
-
equals
-
hashCode
public int hashCode()
-
get(String), or one of the specific format methods.