Interface ArgumentConverter<T>

Type Parameters:
T -

@AvailableSince("0.0.44") public interface ArgumentConverter<T>
Allows defining custom types in sub commands that will be converted before execution. For example, if a sub command uses string parser but would like to receive the string argument as a buffer instead, we can create an argument converter to handle that. The sub command will be able to use the standard string parser but receive an argument buffer instead.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    convert(Object source)
    Convert source object into target type.
    boolean
    Is argument source type supported by this converter.
    Target type of this converter.
  • Method Details

    • isSourceTypeSupported

      boolean isSourceTypeSupported(Class<?> clazz)
      Is argument source type supported by this converter. If an argument is supported, the convert(Object) method should be able to convert it into targetType()
      Parameters:
      clazz - argument source type, cannot be null
      Returns:
      true if supported, else false
    • targetType

      Class<T> targetType()
      Target type of this converter.
      Returns:
      target type
    • convert

      T convert(Object source)
      Convert source object into target type. It is guaranteed that objects provided were already checked for source type support.
      Parameters:
      source - source object
      Returns:
      object of target type