Interface Argument<T>

Type Parameters:
T - The argument type
All Superinterfaces:
AnnotatedElement, AnnotationMetadataProvider, AnnotationSource, Named, Type, TypeInformation<T>, TypeVariableResolver
All Known Subinterfaces:
ArgumentValue<V>, GenericPlaceholder<T>, MutableArgumentValue<V>
All Known Implementing Classes:
ArgumentBeanType, DefaultArgument, GenericArgument

public interface Argument<T> extends TypeInformation<T>, AnnotatedElement, Type
Represents an argument to a method or constructor or type.
Since:
1.0
Author:
Graeme Rocher
  • Field Details

    • STRING

      static final Argument<String> STRING
      Constant for string argument.
    • INT

      static final Argument<Integer> INT
      Constant for int argument. Used by generated code, do not remove.
    • LONG

      static final Argument<Long> LONG
      Constant for long argument. Used by generated code, do not remove.
    • FLOAT

      static final Argument<Float> FLOAT
      Constant for float argument. Used by generated code, do not remove.
    • DOUBLE

      static final Argument<Double> DOUBLE
      Constant for double argument. Used by generated code, do not remove.
    • VOID

      static final Argument<Void> VOID
      Constant for void argument. Used by generated code, do not remove.
    • BYTE

      static final Argument<Byte> BYTE
      Constant for byte argument. Used by generated code, do not remove.
    • BOOLEAN

      static final Argument<Boolean> BOOLEAN
      Constant for boolean argument. Used by generated code, do not remove.
    • CHAR

      static final Argument<Character> CHAR
      Constant char argument. Used by generated code, do not remove.
    • SHORT

      static final Argument<Short> SHORT
      Constant short argument. Used by generated code, do not remove.
    • ZERO_ARGUMENTS

      static final Argument[] ZERO_ARGUMENTS
      Constant representing zero arguments. Used by generated code, do not remove.
    • OBJECT_ARGUMENT

      static final Argument<Object> OBJECT_ARGUMENT
      Default Object argument. Used by generated code, do not remove.
    • LIST_OF_STRING

      static final Argument<List<String>> LIST_OF_STRING
      Constant for List<String> argument.
    • VOID_OBJECT

      static final Argument<Void> VOID_OBJECT
      Constant for Void object argument.
  • Method Details

    • getName

      @NonNull String getName()
      Specified by:
      getName in interface Named
      Returns:
      The name of the argument
    • equalsType

      boolean equalsType(@Nullable Argument<?> other)
      Whether the types are equivalent. The regular Object.equals(Object) implementation includes the argument name within the comparison so this method offers a variation that just compares types.
      Parameters:
      other - The type type
      Returns:
      True if they are equal
    • typeHashCode

      int typeHashCode()
      The hash code including only the types. The regular Object.hashCode() implementation includes the argument name within the comparison so this method offers a variation that just compares types.
      Returns:
      The type hash code
    • isTypeVariable

      default boolean isTypeVariable()
      Whether this argument is a type variable used in generics.
      Returns:
      True if it is a variable
      Since:
      3.0.0
    • isInstance

      default boolean isInstance(@Nullable Object o)
      Whether the given argument is an instance.
      Parameters:
      o - The object
      Returns:
      True if it is an instance of this type
    • isAssignableFrom

      default boolean isAssignableFrom(@NonNull Class<?> candidateType)
      Delegates to Class.isAssignableFrom(Class) for this argument.
      Parameters:
      candidateType - The candidate type
      Returns:
      True if it is assignable from.
      Since:
      3.0.0
    • isAssignableFrom

      default boolean isAssignableFrom(@NonNull Argument<?> candidateArgument)
      Checks if the argument can be assigned to this argument.
      Parameters:
      candidateArgument - The candidate argument
      Returns:
      True if it is assignable from.
      Since:
      3.0.0
    • toClassArray

      @NonNull static Class<?>[] toClassArray(@Nullable Argument<?>... arguments)
      Convert an argument array to a class array.
      Parameters:
      arguments - The arguments
      Returns:
      The class array
    • toString

      @NonNull static String toString(@Nullable Argument<?>... arguments)
      Convert the arguments to a string representation.
      Parameters:
      arguments - The arguments
      Returns:
      The String representation
    • of

      @NonNull static <T> Argument<T> of(@NonNull Class<T> type, @Nullable String name, @Nullable Argument<?>... typeParameters)
      Creates a new argument for the given type and name.
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type
      name - The name
      typeParameters - the type parameters
      Returns:
      The argument instance
    • ofTypeVariable

      @NonNull static <T> Argument<T> ofTypeVariable(@NonNull Class<T> type, @Nullable String name, @Nullable AnnotationMetadata annotationMetadata, @Nullable Argument<?>... typeParameters)
      Creates a new argument for the given type and name that is a type variable.
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type
      name - The name
      annotationMetadata - The annotation metadata
      typeParameters - the type parameters
      Returns:
      The argument instance
      Since:
      3.0.0
    • ofTypeVariable

      @NonNull static <T> Argument<T> ofTypeVariable(@NonNull Class<T> type, @Nullable String argumentName, @NonNull String variableName, @Nullable AnnotationMetadata annotationMetadata, @Nullable Argument<?>... typeParameters)
      Creates a new argument for the given type and name that is a type variable.
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type
      argumentName - The name of the argumennt
      variableName - The variable name
      annotationMetadata - The annotation metadata
      typeParameters - the type parameters
      Returns:
      The argument instance
      Since:
      3.2.0
    • ofTypeVariable

      @NonNull static <T> Argument<T> ofTypeVariable(@NonNull Class<T> type, @Nullable String name)
      Creates a new argument for the given type and name that is a type variable.
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type
      name - The name
      Returns:
      The argument instance
      Since:
      3.0.0
    • ofTypeVariable

      @NonNull static <T> Argument<T> ofTypeVariable(@NonNull Class<T> type, @Nullable String argumentName, @NonNull String variableName)
      Creates a new argument for the given type and name that is a type variable.
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type
      argumentName - The name of the argument
      variableName - The variable name
      Returns:
      The argument instance
      Since:
      3.2.0
    • of

      @NonNull static <T> Argument<T> of(@NonNull Class<T> type, @Nullable String name, @Nullable AnnotationMetadata annotationMetadata, @Nullable Argument<?>... typeParameters)
      Creates a new argument for the given type and name.
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type
      name - The name
      annotationMetadata - the annotation metadata
      typeParameters - the type parameters
      Returns:
      The argument instance
    • of

      @NonNull static <T> Argument<T> of(@NonNull Class<T> type, @Nullable AnnotationMetadata annotationMetadata, @Nullable Argument<?>... typeParameters)
      Creates a new argument for the given type and name.
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type
      annotationMetadata - the annotation metadata
      typeParameters - the type parameters
      Returns:
      The argument instance
    • of

      @NonNull static <T> Argument<T> of(@NonNull Class<T> type, @Nullable String name)
      Creates a new argument for the given type and name.
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type
      name - The name
      Returns:
      The argument instance
    • of

      @NonNull static <T> Argument<T> of(@NonNull Class<T> type, @Nullable Argument<?>... typeParameters)
      Creates a new argument for the given type and name.
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type
      typeParameters - The parameters type
      Returns:
      The argument instance
    • of

      @NonNull static Argument<?> of(@NonNull Type type)
      Allows coercing a Type instance to an Argument.
      Parameters:
      type - The type
      Returns:
      The argument
      Throws:
      IllegalArgumentException - If the type cannot be coerced
      Since:
      3.0.0
    • of

      @NonNull static <T> Argument<T> of(@NonNull Class<T> type)
      Creates a new argument for the given type and name.
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type
      Returns:
      The argument instance
    • of

      @NonNull static <T> Argument<T> of(@NonNull Class<T> type, @Nullable Class<?>... typeParameters)
      Creates a new argument for the given type and name.
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type
      typeParameters - the parameters type
      Returns:
      The argument instance
    • of

      @NonNull static <T> Argument<T> of(@NonNull Class<T> type, @Nullable AnnotationMetadata annotationMetadata, @Nullable Class<?>[] typeParameters)
      Creates a new argument for the given type and name. NOTE: This method should be avoided as it does use the reflection to retrieve the type parameter names.
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type
      annotationMetadata - The annotation metadata
      typeParameters - The parameters type
      Returns:
      The argument instance
      Since:
      3.0.0
    • listOf

      @NonNull static <T> Argument<List<T>> listOf(@NonNull Class<T> type)
      Creates a new argument representing a generic list.
      Type Parameters:
      T - list element type
      Parameters:
      type - list element type
      Returns:
      The argument instance
    • listOf

      @NonNull static <T> Argument<List<T>> listOf(@NonNull Argument<T> type)
      Creates a new argument representing a generic list.
      Type Parameters:
      T - list element type
      Parameters:
      type - list element type
      Returns:
      The argument instance
      Since:
      2.0.1
    • setOf

      @NonNull static <T> Argument<Set<T>> setOf(@NonNull Class<T> type)
      Creates a new argument representing a generic set.
      Type Parameters:
      T - set element type
      Parameters:
      type - set element type
      Returns:
      The argument instance
    • setOf

      @NonNull static <T> Argument<Set<T>> setOf(@NonNull Argument<T> type)
      Creates a new argument representing a generic set.
      Type Parameters:
      T - set element type
      Parameters:
      type - set element type
      Returns:
      The argument instance
      Since:
      2.0.1
    • mapOf

      @NonNull static <K, V> Argument<Map<K,V>> mapOf(@NonNull Class<K> keyType, @NonNull Class<V> valueType)
      Creates a new argument representing a generic map.
      Type Parameters:
      K - The map key type
      V - The map value type
      Parameters:
      keyType - The key type
      valueType - The value type
      Returns:
      The argument instance
    • mapOf

      @NonNull static <K, V> Argument<Map<K,V>> mapOf(@NonNull Argument<K> keyType, @NonNull Argument<V> valueType)
      Creates a new argument representing a generic map.
      Type Parameters:
      K - The map key type
      V - The map value type
      Parameters:
      keyType - The key type
      valueType - The value type
      Returns:
      The argument instance
      Since:
      2.0.1
    • optionalOf

      @NonNull static <T> Argument<Optional<T>> optionalOf(@NonNull Class<T> optionalValueClass)
      Creates a new argument representing an optional.
      Type Parameters:
      T - The optional type
      Parameters:
      optionalValueClass - The optional type
      Returns:
      The argument instance
      Since:
      4.0.0
    • optionalOf

      @NonNull static <T> Argument<Optional<T>> optionalOf(@NonNull Argument<T> optionalValueArgument)
      Creates a new argument representing an optional.
      Type Parameters:
      T - The optional type
      Parameters:
      optionalValueArgument - The optional type
      Returns:
      The argument instance
      Since:
      4.0.0