Class KeyValuesArgumentType<Type extends ArgumentType<TInner>,TInner>

Type Parameters:
Type - The type of the argument type used to parse the values.
TInner - The type of the values.
All Implemented Interfaces:
Parseable<Map<String,TInner>>, ErrorContainer<ArgumentTypeError>, NamedWithDescription, ParentElementGetter<ArgumentType<?>>, PostCreationInheritor<Command>, Resettable

public class KeyValuesArgumentType<Type extends ArgumentType<TInner>,TInner> extends ArgumentType<Map<String,TInner>>
An argument type that takes key-value pairs. The key is a string, and the value is of the argument type given in the constructor. The key-value pairs are separated by an equals sign (e.g. key=value).

The final value of this argument type is a HashMap of the key-value pairs.

See Also:
  • Constructor Details

    • KeyValuesArgumentType

      public KeyValuesArgumentType(@NotNull Type argumentType)
      Creates a new key-values argument type.
      Parameters:
      argumentType - The argument type used to parse the values.
  • Method Details

    • getValueCountBounds

      @NotNull public @NotNull io.github.darvil.utils.Range getValueCountBounds()
      Description copied from interface: Parseable
      Specifies the number of values that this parser should receive when calling Parseable.parseValues(String[]). By default, this is 1. (Range.ONE).
    • parseValues

      public Map<@NotNull String,@NotNull TInner> parseValues(String @NotNull [] values)
      Description copied from interface: Parseable
      Parses the received values and returns the result. If the values are invalid, this method shall return null.
      Parameters:
      values - The values that were received.
      Returns:
      The parsed value.
    • getRepresentation

      @NotNull public @NotNull io.github.darvil.terminal.textformatter.TextFormatter getRepresentation()
      Description copied from interface: Parseable
      Returns the representation of this parseable type. This may appear in places like the help message.
    • getDescription

      @Nullable public @Nullable String getDescription()
      Description copied from interface: NamedWithDescription
      Returns the description of this object.
      Returns:
      The description of this object