Package io.micronaut.core.type
Class DefaultArgument<T>
- java.lang.Object
-
- io.micronaut.core.type.DefaultArgument<T>
-
- Type Parameters:
T
- The argument type
- All Implemented Interfaces:
AnnotatedElement
,AnnotationMetadataProvider
,AnnotationSource
,Named
,Argument<T>
,ArgumentCoercible<T>
,TypeInformation<T>
,TypeVariableResolver
,java.lang.reflect.Type
- Direct Known Subclasses:
GenericArgument
@Internal public class DefaultArgument<T> extends java.lang.Object implements Argument<T>, ArgumentCoercible<T>
Represents an argument to a constructor or method.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Set<java.lang.Class<?>>
CONTAINER_TYPES
static java.util.Set<java.lang.String>
PROVIDER_TYPES
-
Fields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY
-
Fields inherited from interface io.micronaut.core.type.Argument
BOOLEAN, BYTE, CHAR, DOUBLE, FLOAT, INT, LIST_OF_STRING, LONG, OBJECT_ARGUMENT, SHORT, STRING, VOID, VOID_OBJECT, ZERO_ARGUMENTS
-
-
Constructor Summary
Constructors Modifier Constructor Description DefaultArgument(java.lang.Class<T> type, AnnotationMetadata annotationMetadata, Argument<?>... genericTypes)
DefaultArgument(java.lang.Class<T> type, java.lang.String name, AnnotationMetadata annotationMetadata, boolean isTypeVariable, Argument<?>... genericTypes)
DefaultArgument(java.lang.Class<T> type, java.lang.String name, AnnotationMetadata annotationMetadata, Argument<?>... genericTypes)
DefaultArgument(java.lang.Class<T> type, java.lang.String name, AnnotationMetadata annotationMetadata, java.util.Map<java.lang.String,Argument<?>> typeParameters, Argument<?>[] typeParameterArray)
protected
DefaultArgument(java.lang.Class<T> type, java.lang.String name, AnnotationMetadata annotationMetadata, java.util.Map<java.lang.String,Argument<?>> typeParameters, Argument<?>[] typeParameterArray, boolean isTypeVariable)
DefaultArgument(java.lang.reflect.Type type, java.lang.String name, AnnotationMetadata annotationMetadata)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Argument<T>
asArgument()
boolean
equals(java.lang.Object o)
boolean
equalsType(Argument<?> o)
Whether the types are equivalent.AnnotationMetadata
getAnnotationMetadata()
Supplies the metadata.java.util.Optional<Argument<?>>
getFirstTypeVariable()
java.lang.String
getName()
java.lang.Class<T>
getType()
Argument[]
getTypeParameters()
java.util.Map<java.lang.String,Argument<?>>
getTypeVariables()
int
hashCode()
boolean
isTypeVariable()
Whether this argument is a type variable used in generics.java.lang.String
toString()
int
typeHashCode()
The hash code including only the types.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
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, 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.Argument
isAssignableFrom, isAssignableFrom, isInstance
-
Methods inherited from interface io.micronaut.core.type.TypeInformation
asParameterizedType, asType, getSimpleName, 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
getTypeVariable
-
-
-
-
Constructor Detail
-
DefaultArgument
public DefaultArgument(java.lang.Class<T> type, java.lang.String name, AnnotationMetadata annotationMetadata, Argument<?>... genericTypes)
- Parameters:
type
- The typename
- The nameannotationMetadata
- The annotation metadatagenericTypes
- The generic types
-
DefaultArgument
public DefaultArgument(java.lang.Class<T> type, AnnotationMetadata annotationMetadata, Argument<?>... genericTypes)
- Parameters:
type
- The typeannotationMetadata
- The annotation metadatagenericTypes
- The generic types
-
DefaultArgument
public DefaultArgument(java.lang.Class<T> type, java.lang.String name, AnnotationMetadata annotationMetadata, java.util.Map<java.lang.String,Argument<?>> typeParameters, Argument<?>[] typeParameterArray)
- Parameters:
type
- The typename
- The nameannotationMetadata
- The annotation metadatatypeParameters
- The map of parameterstypeParameterArray
- The array of arguments
-
DefaultArgument
public DefaultArgument(java.lang.Class<T> type, java.lang.String name, AnnotationMetadata annotationMetadata, boolean isTypeVariable, Argument<?>... genericTypes)
- Parameters:
type
- The typename
- The nameannotationMetadata
- The annotation metadataisTypeVariable
- Is this argument a type variablegenericTypes
- The generic types
-
DefaultArgument
protected DefaultArgument(java.lang.Class<T> type, java.lang.String name, AnnotationMetadata annotationMetadata, java.util.Map<java.lang.String,Argument<?>> typeParameters, Argument<?>[] typeParameterArray, boolean isTypeVariable)
- Parameters:
type
- The typename
- The nameannotationMetadata
- The annotation metadatatypeParameters
- The map of parameterstypeParameterArray
- The array of argumentsisTypeVariable
- Is the argument a type variable
-
DefaultArgument
public DefaultArgument(java.lang.reflect.Type type, java.lang.String name, AnnotationMetadata annotationMetadata)
- Parameters:
type
- The typename
- The nameannotationMetadata
- The annotation metadata
-
-
Method Detail
-
isTypeVariable
public boolean isTypeVariable()
Description copied from interface:Argument
Whether this argument is a type variable used in generics.- Specified by:
isTypeVariable
in interfaceArgument<T>
- Returns:
- True if it is a variable
-
getAnnotationMetadata
public AnnotationMetadata getAnnotationMetadata()
Description copied from interface:AnnotationMetadataProvider
Supplies the metadata. Defaults toAnnotationMetadata.EMPTY_METADATA
.- Specified by:
getAnnotationMetadata
in interfaceAnnotationMetadataProvider
- Returns:
- The
AnnotationMetadata
-
getFirstTypeVariable
public java.util.Optional<Argument<?>> getFirstTypeVariable()
- Specified by:
getFirstTypeVariable
in interfaceTypeVariableResolver
- Returns:
- Return the first type parameter if it is present
-
getTypeParameters
public Argument[] getTypeParameters()
- Specified by:
getTypeParameters
in interfaceTypeVariableResolver
- Returns:
- The type parameters as an array
-
getTypeVariables
public java.util.Map<java.lang.String,Argument<?>> getTypeVariables()
- Specified by:
getTypeVariables
in interfaceTypeVariableResolver
- Returns:
- Obtain a map of the type parameters for the argument
-
getType
@NonNull public java.lang.Class<T> getType()
- Specified by:
getType
in interfaceTypeInformation<T>
- Returns:
- The type
-
getName
@NonNull public java.lang.String getName()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equalsType
public boolean equalsType(@Nullable Argument<?> o)
Description copied from interface:Argument
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.- Specified by:
equalsType
in interfaceArgument<T>
- Parameters:
o
- The type type- Returns:
- True if they are equal
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
typeHashCode
public int typeHashCode()
Description copied from interface:Argument
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.- Specified by:
typeHashCode
in interfaceArgument<T>
- Returns:
- The type hash code
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
asArgument
@NonNull public Argument<T> asArgument()
- Specified by:
asArgument
in interfaceArgumentCoercible<T>
- Returns:
- The argument
-
-