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_TYPESstatic 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)protectedDefaultArgument(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()booleanequals(java.lang.Object o)booleanequalsType(Argument<?> o)Whether the types are equivalent.AnnotationMetadatagetAnnotationMetadata()Supplies the metadata.java.util.Optional<Argument<?>>getFirstTypeVariable()java.lang.StringgetName()java.lang.Class<T>getType()Argument[]getTypeParameters()java.util.Map<java.lang.String,Argument<?>>getTypeVariables()inthashCode()booleanisTypeVariable()Whether this argument is a type variable used in generics.java.lang.StringtoString()inttypeHashCode()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:ArgumentWhether this argument is a type variable used in generics.- Specified by:
isTypeVariablein interfaceArgument<T>- Returns:
- True if it is a variable
-
getAnnotationMetadata
public AnnotationMetadata getAnnotationMetadata()
Description copied from interface:AnnotationMetadataProviderSupplies the metadata. Defaults toAnnotationMetadata.EMPTY_METADATA.- Specified by:
getAnnotationMetadatain interfaceAnnotationMetadataProvider- Returns:
- The
AnnotationMetadata
-
getFirstTypeVariable
public java.util.Optional<Argument<?>> getFirstTypeVariable()
- Specified by:
getFirstTypeVariablein interfaceTypeVariableResolver- Returns:
- Return the first type parameter if it is present
-
getTypeParameters
public Argument[] getTypeParameters()
- Specified by:
getTypeParametersin interfaceTypeVariableResolver- Returns:
- The type parameters as an array
-
getTypeVariables
public java.util.Map<java.lang.String,Argument<?>> getTypeVariables()
- Specified by:
getTypeVariablesin interfaceTypeVariableResolver- Returns:
- Obtain a map of the type parameters for the argument
-
getType
@NonNull public java.lang.Class<T> getType()
- Specified by:
getTypein interfaceTypeInformation<T>- Returns:
- The type
-
getName
@NonNull public java.lang.String getName()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equalsType
public boolean equalsType(@Nullable Argument<?> o)
Description copied from interface:ArgumentWhether 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:
equalsTypein interfaceArgument<T>- Parameters:
o- The type type- Returns:
- True if they are equal
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
typeHashCode
public int typeHashCode()
Description copied from interface:ArgumentThe 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:
typeHashCodein interfaceArgument<T>- Returns:
- The type hash code
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
asArgument
@NonNull public Argument<T> asArgument()
- Specified by:
asArgumentin interfaceArgumentCoercible<T>- Returns:
- The argument
-
-