Package io.ran.token

Class Token

java.lang.Object
io.ran.token.Token

public class Token extends Object
  • Field Details

  • Method Details

    • get

      public static Token get(@Nonnull String anyFormat)
      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 public static Token of(@Nonnull String... parts)
      Deprecated.
      You should probably use get(String), or one of the specific format methods. If you know what you're doing, suppress the warning
      Create a token consisting exactly of the parts specified.
    • of

      @Deprecated public static Token of(@Nonnull List<String> parts)
      Deprecated.
      You should probably use get(String), or one of the specific format methods. If you know what you're doing, suppress the warning
      Create a token consisting exactly of the parts specified.
    • literal

      public static Token literal(@Nonnull String 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

      public static Token PascalCase(@Nonnull String tokenString)
      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

      public static Token camelCase(@Nonnull String tokenString)
      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

      public static Token snake_case(@Nonnull String tokenString)
      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

      public static Token Human_readable(@Nonnull String tokenString)
      Parses a human-readable string into a token. This will throw an exception if the string is not in human-readable format

      A 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

      public static Token javaMethod(@Nonnull String tokenString)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • stringLength

      public int stringLength()
      Returns:
      the total number of characters in all the parts of this token
    • getParts

      public List<String> 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

      public String PascalCase()
      Returns:
      a string in PascalCase format representing this token
    • camelCase

      public String camelCase()
      Returns:
      a string in camelCase format representing this token
    • snake_case

      public String snake_case()
      Returns:
      a string in snake_case format representing this token
    • Human_readable

      public String Human_readable()
      Returns:
      a string in Human readable format representing this token
    • javaMethod

      public String javaMethod()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object