Class TypeParserRegistry.SimpleTypeParser<T>

java.lang.Object
com.ultikits.ultitools.abstracts.command.parser.TypeParserRegistry.SimpleTypeParser<T>
All Implemented Interfaces:
TypeParser<T>
Enclosing class:
TypeParserRegistry

private static class TypeParserRegistry.SimpleTypeParser<T> extends Object implements TypeParser<T>
Simple implementation of TypeParser using a parsing function.
  • Field Details

    • primaryType

      private final Class<T> primaryType
    • parseFunction

      private final Function<String,T> parseFunction
    • supportedTypes

      private final List<Class<?>> supportedTypes
    • priority

      private final int priority
  • Constructor Details

  • Method Details

    • getPrimaryType

      public Class<T> getPrimaryType()
      Description copied from interface: TypeParser
      Gets the primary type this parser handles.
      Specified by:
      getPrimaryType in interface TypeParser<T>
      Returns:
      the primary type class
    • getSupportedTypes

      public List<Class<?>> getSupportedTypes()
      Description copied from interface: TypeParser
      Gets all types this parser can handle, including array types.
      Specified by:
      getSupportedTypes in interface TypeParser<T>
      Returns:
      list of supported types
    • parse

      @Nullable public T parse(String value) throws TypeParseException
      Description copied from interface: TypeParser
      Parses a string value into the target type.
      Specified by:
      parse in interface TypeParser<T>
      Parameters:
      value - the string value to parse
      Returns:
      the parsed value, or null if parsing fails
      Throws:
      TypeParseException - if parsing fails with an error
    • getPriority

      public int getPriority()
      Description copied from interface: TypeParser
      Gets the priority of this parser. Higher priority parsers are checked first. Default priority is 0.
      Specified by:
      getPriority in interface TypeParser<T>
      Returns:
      the parser priority