Package io.micronaut.core.type
Interface Argument<T>
-
- Type Parameters:
T- The argument type
- All Superinterfaces:
AnnotatedElement,AnnotationMetadataProvider,AnnotationSource,Named,java.lang.reflect.Type,TypeInformation<T>,TypeVariableResolver
- All Known Subinterfaces:
ArgumentValue<V>,GenericPlaceholder<T>,MutableArgumentValue<V>
- All Known Implementing Classes:
DefaultArgument,GenericArgument
public interface Argument<T> extends TypeInformation<T>, AnnotatedElement, java.lang.reflect.Type
Represents an argument to a method or constructor or type.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static Argument<java.lang.Boolean>BOOLEANConstant for boolean argument.static Argument<java.lang.Byte>BYTEConstant for byte argument.static Argument<java.lang.Character>CHARConstant char argument.static Argument<java.lang.Double>DOUBLEConstant for double argument.static Argument<java.lang.Float>FLOATConstant for float argument.static Argument<java.lang.Integer>INTConstant for int argument.static Argument<java.util.List<java.lang.String>>LIST_OF_STRINGConstant forList<String>argument.static Argument<java.lang.Long>LONGConstant for long argument.static Argument<java.lang.Object>OBJECT_ARGUMENTDefault Object argument.static Argument<java.lang.Short>SHORTConstant short argument.static Argument<java.lang.String>STRINGConstant for string argument.static Argument<java.lang.Void>VOIDConstant for void argument.static Argument<java.lang.Void>VOID_OBJECTConstant for Void object argument.static Argument[]ZERO_ARGUMENTSConstant representing zero arguments.-
Fields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleanequalsType(Argument<?> other)Whether the types are equivalent.java.lang.StringgetName()default booleanisAssignableFrom(Argument<?> candidateArgument)Checks if the argument can be assigned to this argument.default booleanisAssignableFrom(java.lang.Class<?> candidateType)Delegates toClass.isAssignableFrom(Class)for this argument.default booleanisInstance(java.lang.Object o)Whether the given argument is an instance.default booleanisTypeVariable()Whether this argument is a type variable used in generics.static <T> Argument<java.util.List<T>>listOf(Argument<T> type)Creates a new argument representing a generic list.static <T> Argument<java.util.List<T>>listOf(java.lang.Class<T> type)Creates a new argument representing a generic list.static <K,V>
Argument<java.util.Map<K,V>>mapOf(Argument<K> keyType, Argument<V> valueType)Creates a new argument representing a generic map.static <K,V>
Argument<java.util.Map<K,V>>mapOf(java.lang.Class<K> keyType, java.lang.Class<V> valueType)Creates a new argument representing a generic map.static <T> Argument<T>of(java.lang.Class<T> type)Creates a new argument for the given type and name.static <T> Argument<T>of(java.lang.Class<T> type, AnnotationMetadata annotationMetadata, Argument<?>... typeParameters)Creates a new argument for the given type and name.static <T> Argument<T>of(java.lang.Class<T> type, AnnotationMetadata annotationMetadata, java.lang.Class<?>[] typeParameters)Creates a new argument for the given type and name.static <T> Argument<T>of(java.lang.Class<T> type, Argument<?>... typeParameters)Creates a new argument for the given type and name.static <T> Argument<T>of(java.lang.Class<T> type, java.lang.Class<?>... typeParameters)Creates a new argument for the given type and name.static <T> Argument<T>of(java.lang.Class<T> type, java.lang.String name)Creates a new argument for the given type and name.static <T> Argument<T>of(java.lang.Class<T> type, java.lang.String name, AnnotationMetadata annotationMetadata, Argument<?>... typeParameters)Creates a new argument for the given type and name.static <T> Argument<T>of(java.lang.Class<T> type, java.lang.String name, Argument<?>... typeParameters)Creates a new argument for the given type and name.static Argument<?>of(java.lang.reflect.Type type)Allows coercing aTypeinstance to anArgument.static <T> Argument<T>ofTypeVariable(java.lang.Class<T> type, java.lang.String name)Creates a new argument for the given type and name that is a type variable.static <T> Argument<T>ofTypeVariable(java.lang.Class<T> type, java.lang.String name, AnnotationMetadata annotationMetadata, Argument<?>... typeParameters)Creates a new argument for the given type and name that is a type variable.static <T> Argument<T>ofTypeVariable(java.lang.Class<T> type, java.lang.String argumentName, java.lang.String variableName)Creates a new argument for the given type and name that is a type variable.static <T> Argument<T>ofTypeVariable(java.lang.Class<T> type, java.lang.String argumentName, java.lang.String variableName, AnnotationMetadata annotationMetadata, Argument<?>... typeParameters)Creates a new argument for the given type and name that is a type variable.static <T> Argument<java.util.Set<T>>setOf(Argument<T> type)Creates a new argument representing a generic set.static <T> Argument<java.util.Set<T>>setOf(java.lang.Class<T> type)Creates a new argument representing a generic set.static java.lang.Class<?>[]toClassArray(Argument<?>... arguments)Convert an argument array to a class array.static java.lang.StringtoString(Argument<?>... arguments)Convert the arguments to a string representation.inttypeHashCode()The hash code including only the types.-
Methods inherited from interface io.micronaut.core.annotation.AnnotatedElement
isDeclaredNonNull, isDeclaredNullable, isNonNull, isNullable
-
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataProvider
findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, getAnnotationMetadata, isAnnotationPresent, isDeclaredAnnotationPresent, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByType
-
Methods inherited from interface io.micronaut.core.annotation.AnnotationSource
getAnnotation, getAnnotation, getDeclaredAnnotation, getDeclaredAnnotation, isAnnotationPresent, isDeclaredAnnotationPresent, synthesize, synthesizeDeclared
-
Methods inherited from interface io.micronaut.core.type.TypeInformation
asParameterizedType, asType, getSimpleName, getType, getTypeName, getTypeString, getWrappedType, getWrapperType, hasTypeVariables, isArray, isAsync, isAsyncOrReactive, isCompletable, isContainerType, isOptional, isPrimitive, isProvider, isReactive, isSpecifiedSingle, isVoid, isWrapperType
-
Methods inherited from interface io.micronaut.core.type.TypeVariableResolver
getFirstTypeVariable, getTypeParameters, getTypeVariable, getTypeVariables
-
-
-
-
Field Detail
-
STRING
static final Argument<java.lang.String> STRING
Constant for string argument.
-
INT
static final Argument<java.lang.Integer> INT
Constant for int argument. Used by generated code, do not remove.
-
LONG
static final Argument<java.lang.Long> LONG
Constant for long argument. Used by generated code, do not remove.
-
FLOAT
static final Argument<java.lang.Float> FLOAT
Constant for float argument. Used by generated code, do not remove.
-
DOUBLE
static final Argument<java.lang.Double> DOUBLE
Constant for double argument. Used by generated code, do not remove.
-
VOID
static final Argument<java.lang.Void> VOID
Constant for void argument. Used by generated code, do not remove.
-
BYTE
static final Argument<java.lang.Byte> BYTE
Constant for byte argument. Used by generated code, do not remove.
-
BOOLEAN
static final Argument<java.lang.Boolean> BOOLEAN
Constant for boolean argument. Used by generated code, do not remove.
-
CHAR
static final Argument<java.lang.Character> CHAR
Constant char argument. Used by generated code, do not remove.
-
SHORT
static final Argument<java.lang.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<java.lang.Object> OBJECT_ARGUMENT
Default Object argument. Used by generated code, do not remove.
-
LIST_OF_STRING
static final Argument<java.util.List<java.lang.String>> LIST_OF_STRING
Constant forList<String>argument.
-
VOID_OBJECT
static final Argument<java.lang.Void> VOID_OBJECT
Constant for Void object argument.
-
-
Method Detail
-
getName
@NonNull java.lang.String getName()
-
equalsType
boolean equalsType(@Nullable Argument<?> other)
Whether the types are equivalent. The regularObject.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 regularObject.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 java.lang.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 java.lang.Class<?> candidateType)
Delegates toClass.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 java.lang.Class<?>[] toClassArray(@Nullable Argument<?>... arguments)
Convert an argument array to a class array.- Parameters:
arguments- The arguments- Returns:
- The class array
-
toString
@NonNull static java.lang.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 java.lang.Class<T> type, @Nullable java.lang.String name, @Nullable Argument<?>... typeParameters)
Creates a new argument for the given type and name.- Type Parameters:
T- The generic type- Parameters:
type- The typename- The nametypeParameters- the type parameters- Returns:
- The argument instance
-
ofTypeVariable
@NonNull static <T> Argument<T> ofTypeVariable(@NonNull java.lang.Class<T> type, @Nullable java.lang.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 typename- The nameannotationMetadata- The annotation metadatatypeParameters- the type parameters- Returns:
- The argument instance
- Since:
- 3.0.0
-
ofTypeVariable
@NonNull static <T> Argument<T> ofTypeVariable(@NonNull java.lang.Class<T> type, @Nullable java.lang.String argumentName, @NonNull java.lang.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 typeargumentName- The name of the argumenntvariableName- The variable nameannotationMetadata- The annotation metadatatypeParameters- the type parameters- Returns:
- The argument instance
- Since:
- 3.2.0
-
ofTypeVariable
@NonNull static <T> Argument<T> ofTypeVariable(@NonNull java.lang.Class<T> type, @Nullable java.lang.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 typename- The name- Returns:
- The argument instance
- Since:
- 3.0.0
-
ofTypeVariable
@NonNull static <T> Argument<T> ofTypeVariable(@NonNull java.lang.Class<T> type, @Nullable java.lang.String argumentName, @NonNull java.lang.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 typeargumentName- The name of the argumentvariableName- The variable name- Returns:
- The argument instance
- Since:
- 3.2.0
-
of
@NonNull static <T> Argument<T> of(@NonNull java.lang.Class<T> type, @Nullable java.lang.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 typename- The nameannotationMetadata- the annotation metadatatypeParameters- the type parameters- Returns:
- The argument instance
-
of
@NonNull static <T> Argument<T> of(@NonNull java.lang.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 typeannotationMetadata- the annotation metadatatypeParameters- the type parameters- Returns:
- The argument instance
-
of
@NonNull static <T> Argument<T> of(@NonNull java.lang.Class<T> type, @Nullable java.lang.String name)
Creates a new argument for the given type and name.- Type Parameters:
T- The generic type- Parameters:
type- The typename- The name- Returns:
- The argument instance
-
of
@NonNull static <T> Argument<T> of(@NonNull java.lang.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 typetypeParameters- The parameters type- Returns:
- The argument instance
-
of
@NonNull static Argument<?> of(@NonNull java.lang.reflect.Type type)
Allows coercing aTypeinstance to anArgument.- Parameters:
type- The type- Returns:
- The argument
- Throws:
java.lang.IllegalArgumentException- If the type cannot be coerced- Since:
- 3.0.0
-
of
@NonNull static <T> Argument<T> of(@NonNull java.lang.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 java.lang.Class<T> type, @Nullable java.lang.Class<?>... typeParameters)
Creates a new argument for the given type and name.- Type Parameters:
T- The generic type- Parameters:
type- The typetypeParameters- the parameters type- Returns:
- The argument instance
-
of
@NonNull static <T> Argument<T> of(@NonNull java.lang.Class<T> type, @Nullable AnnotationMetadata annotationMetadata, @Nullable java.lang.Class<?>[] typeParameters)
Creates a new argument for the given type and name.- Type Parameters:
T- The generic type- Parameters:
type- The typeannotationMetadata- The annotation metadatatypeParameters- The parameters type- Returns:
- The argument instance
- Since:
- 3.0.0
-
listOf
@NonNull static <T> Argument<java.util.List<T>> listOf(@NonNull java.lang.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<java.util.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<java.util.Set<T>> setOf(@NonNull java.lang.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<java.util.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<java.util.Map<K,V>> mapOf(@NonNull java.lang.Class<K> keyType, @NonNull java.lang.Class<V> valueType)
Creates a new argument representing a generic map.- Type Parameters:
K- The map key typeV- The map value type- Parameters:
keyType- The key typevalueType- The value type- Returns:
- The argument instance
-
mapOf
@NonNull static <K,V> Argument<java.util.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 typeV- The map value type- Parameters:
keyType- The key typevalueType- The value type- Returns:
- The argument instance
- Since:
- 2.0.1
-
-