Class ServiceArgument<T>

  • Type Parameters:
    T - the type of the argument
    Direct Known Subclasses:
    DynamicArgument

    @PublicAPI
    public class ServiceArgument<T>
    extends Object
    Describes an argument passed to services
    Since:
    5.6
    • Field Detail

      • type

        protected Class<T> type
        type of the argument
      • value

        protected T value
        value of the argument
      • constant

        protected final boolean constant
        field indicates constant argument
      • name

        protected String name
        the name of the argument
      • alias

        protected String alias
        the alias of the argument
    • Constructor Detail

      • ServiceArgument

        protected ServiceArgument​(Class<T> type,
                                  T value)
        Constructs a service argument with specified type and value
        Parameters:
        type - the argument type
        value - the argument value
      • ServiceArgument

        protected ServiceArgument​(Class<T> type,
                                  T value,
                                  boolean constant)
        Constructs a service argument with specified type and value
        Parameters:
        type - the argument type
        value - the argument value
        constant - the constant flag
    • Method Detail

      • createArgument

        public static <T> ServiceArgument<T> createArgument​(T value)
        Returns a service argument based on value
        Type Parameters:
        T - the argument type
        Parameters:
        value - the argument value
        Returns:
        a constant service argument based on value
      • createArgument

        public static <T> ServiceArgument<T> createArgument​(String name,
                                                            T value)
        Returns a service argument based on value
        Type Parameters:
        T - the argument type
        Parameters:
        name - argument name
        value - the argument value
        Returns:
        a constant service argument based on value
      • createArgumentAs

        public static <T> ServiceArgument<T> createArgumentAs​(T value,
                                                              Class<T> type)
        Returns a service argument based on value and type
        Type Parameters:
        T - the argument type
        Parameters:
        value - the argument value
        type - the argument type
        Returns:
        a constant service argument based on value
      • createArgumentAs

        public static <T> ServiceArgument<T> createArgumentAs​(String name,
                                                              T value,
                                                              Class<T> type)
        Returns a service argument based on value and type
        Type Parameters:
        T - the argument type
        Parameters:
        name - the argument name
        value - the argument value
        type - the argument type
        Returns:
        a constant service argument based on value
      • getType

        public Class<T> getType()
        Returns the argument type
        Returns:
        the argument type
      • setType

        public void setType​(Class<T> argumentType)
        Sets the class of the argument
        Parameters:
        argumentType - the argument class
      • getValue

        public T getValue()
        Returns the argument value
        Returns:
        the argument value
      • setValue

        public void setValue​(T value)
        Sets the service argument value
        Parameters:
        value - the new value
      • isValid

        public boolean isValid()
        Returns true if service argument is valid
        Returns:
        true if service argument is valid
      • getName

        public String getName()
        Returns the name of the argument
        Returns:
        the name of the argument
      • setName

        public void setName​(String name)
        Sets the name of the argument
        Parameters:
        name - the new argument name
      • getAlias

        public String getAlias()
        Returns the argument alias. Aliases may be used to call services in a user friendly way by parsing user input.
        Returns:
        the argument alias or null if no alias set
      • setAlias

        public void setAlias​(String alias)
        Sets the argument alias. Aliases may be used to call services in a user friendly way by parsing user input.
        Parameters:
        alias - the new alias