Class TypedArgument<T>


  • public class TypedArgument<T>
    extends Argument
    An implementation of Argument for java specifying the type of object received by the argument. This allows converting the given raw value into the specified type.
    Author:
    Clement Escoffier
    • Field Detail

      • type

        protected Class<T> type
        The type of the argument.
      • converter

        protected Converter<T> converter
        The converter to use to create the value.
    • Constructor Detail

      • TypedArgument

        public TypedArgument()
        Creates an empty instance of TypedArgument.
    • Method Detail

      • getType

        public Class<T> getType()
        Returns:
        the argument type, cannot be null for valid argument.
      • getConverter

        public Converter<T> getConverter()
        Returns:
        the converter used to create the value, null if not set
      • setConverter

        public TypedArgument<T> setConverter​(Converter<T> converter)
        Sets the converter used to create the value.
        Parameters:
        converter - the converter
        Returns:
        the current TypedArgument instance
      • ensureValidity

        public void ensureValidity()
        Checks whether or not the argument configuration is valid. In addition of the check made by the parent class it ensures that the type is set. If the configuration is not valid, this method throws a IllegalArgumentException.
        Overrides:
        ensureValidity in class Argument
      • setIndex

        public TypedArgument<T> setIndex​(int index)
        Description copied from class: Argument
        Sets the argument index.
        Overrides:
        setIndex in class Argument
        Parameters:
        index - the index, must not be negative
        Returns:
        the current Argument instance
      • setRequired

        public TypedArgument<T> setRequired​(boolean required)
        Description copied from class: Argument
        Sets whether or not the current Argument is required.
        Overrides:
        setRequired in class Argument
        Parameters:
        required - true to make this argument mandatory, {@link false} otherwise
        Returns:
        the current Argument instance
      • setMultiValued

        public TypedArgument<T> setMultiValued​(boolean multiValued)
        Description copied from class: Argument
        Sets whether or not the argument can receive several values. Only the last argument can receive several values.
        Overrides:
        setMultiValued in class Argument
        Parameters:
        multiValued - true to mark this argument as multi-valued.
        Returns:
        the current Argument instance