Class TypeUtils
java.lang.Object
io.micronaut.data.processor.visitors.finders.TypeUtils
Internal utility methods.
- Since:
- 1.0.0
- Author:
- graemerocher
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanareTypesCompatible(io.micronaut.inject.ast.ClassElement leftType, io.micronaut.inject.ast.ClassElement rightType) Return true if the left type is compatible or can be assigned to the right type.static booleandoesMethodProducesABoolean(io.micronaut.inject.ast.MethodElement methodElement) Does the given method element return boolean.static booleandoesMethodProducesAnEntityIterableOfAnEntity(io.micronaut.inject.ast.MethodElement methodElement) Checks whether the return type is supported.static booleandoesMethodProducesANumber(io.micronaut.inject.ast.MethodElement methodElement) Does the method return an object convertible to a number.static booleandoesMethodProducesIterable(io.micronaut.inject.ast.MethodElement methodElement) Checks whether the return type is supported.static booleandoesMethodProducesIterableOfAnEntityOrDto(io.micronaut.inject.ast.MethodElement methodElement) Checks whether the return type is supported.static booleandoesReturnVoid(io.micronaut.inject.ast.MethodElement methodElement) Does the method element return void.static @Nullable io.micronaut.inject.ast.ClassElementgetKotlinCoroutineProducedType(io.micronaut.inject.ast.MethodElement methodElement) static @Nullable io.micronaut.inject.ast.ClassElementgetMethodProducingItemType(io.micronaut.inject.ast.MethodElement methodElement) static StringgetTypeName(io.micronaut.inject.ast.ClassElement type) Return the type for the given class element, wrapping primitives types if necessary.static booleanhasPersistedTypeArgument(@Nullable io.micronaut.inject.ast.ClassElement type) Does the given type have a first argument annotated withMappedEntity.static booleanisBoolean(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a boolean.static booleanisComparable(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a number.static booleanisContainerType(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a container type such as a collection etc.static booleanisDto(@Nullable io.micronaut.inject.ast.ClassElement type) Does the given type have anIntrospected.static booleanisEntity(@Nullable io.micronaut.inject.ast.ClassElement type) Does the given type have anMappedEntity.static booleanisEntityContainerType(@Nullable io.micronaut.inject.ast.ClassElement type) Is the given type a container type of entity.static booleanisEntityOfType(@Nullable io.micronaut.inject.ast.ClassElement type, @NonNull io.micronaut.inject.ast.ClassElement entityType) Checks if the given type is an entity of the specified type.static booleanisEntityOrDto(@Nullable io.micronaut.inject.ast.ClassElement type) Does the given type have anMappedEntityorIntrospected.static booleanisFutureType(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a future type.static booleanisIterableOfDto(@Nullable io.micronaut.inject.ast.ClassElement type) Is the element an iterable of a DTO.static booleanisIterableOfEntity(@Nullable io.micronaut.inject.ast.ClassElement type) Is the element an iterable of an entity.static booleanisIterableOfEntityType(@Nullable io.micronaut.inject.ast.ClassElement type, @NonNull io.micronaut.inject.ast.ClassElement entityType) Checks if the given type is an iterable (or array) of entities of the specified type.static booleanisNumber(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a number.static booleanisObjectClass(io.micronaut.inject.ast.ClassElement type) Whether the given type is Object.static booleanisPeriod(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a period.static booleanisReactiveOrFuture(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a future type.static booleanisReactiveSingleResult(@Nullable io.micronaut.inject.ast.ClassElement type) Is the reactive type a single-result type, i.e.static booleanisReactiveType(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a reactive type.static booleanisTextual(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a string.static booleanisValidBatchUpdateReturnType(io.micronaut.inject.ast.MethodElement methodElement) Returns true if the return type is considered valid for batch update operations likes deletes and updates.static booleanisValidCountReturnType(MatchContext matchContext) Checks whether the return type is supported.static booleanisVoid(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type void.static @Nullable StringresolveDataConverter(io.micronaut.inject.ast.ClassElement type, Map<String, String> dataConverters) Resolve the converter for the given type.static DataTyperesolveDataType(io.micronaut.inject.ast.ClassElement type, Map<String, DataType> dataTypes) Compute the data type for the given type.resolveDataType(io.micronaut.inject.ast.ParameterElement parameter) Compute the data type for the given parameter.
-
Constructor Details
-
TypeUtils
public TypeUtils()
-
-
Method Details
-
getKotlinCoroutineProducedType
public static @Nullable io.micronaut.inject.ast.ClassElement getKotlinCoroutineProducedType(io.micronaut.inject.ast.MethodElement methodElement) -
isIterableOfEntity
public static boolean isIterableOfEntity(@Nullable io.micronaut.inject.ast.ClassElement type) Is the element an iterable of an entity.- Parameters:
type- The type- Returns:
- True if is
-
isIterableOfDto
public static boolean isIterableOfDto(@Nullable io.micronaut.inject.ast.ClassElement type) Is the element an iterable of a DTO.- Parameters:
type- The type- Returns:
- True if is
-
isEntityContainerType
public static boolean isEntityContainerType(@Nullable io.micronaut.inject.ast.ClassElement type) Is the given type a container type of entity.- Parameters:
type- The type- Returns:
- True if it is
-
isEntityOrDto
public static boolean isEntityOrDto(@Nullable io.micronaut.inject.ast.ClassElement type) Does the given type have anMappedEntityorIntrospected.- Parameters:
type- The type- Returns:
- True if it does
-
isEntity
public static boolean isEntity(@Nullable io.micronaut.inject.ast.ClassElement type) Does the given type have anMappedEntity.- Parameters:
type- The type- Returns:
- True if it does
-
isEntityOfType
public static boolean isEntityOfType(@Nullable io.micronaut.inject.ast.ClassElement type, @NonNull io.micronaut.inject.ast.ClassElement entityType) Checks if the given type is an entity of the specified type. A type is considered an entity if it is annotated withMappedEntityand is not an array. The type is considered to be of the specified entity type if it is the same type or a subtype of the entity type.- Parameters:
type- The type to check. May be null.entityType- The expected entity type. Must not be null.- Returns:
- true if the type is an entity of the given type, false otherwise.
-
isIterableOfEntityType
public static boolean isIterableOfEntityType(@Nullable io.micronaut.inject.ast.ClassElement type, @NonNull io.micronaut.inject.ast.ClassElement entityType) Checks if the given type is an iterable (or array) of entities of the specified type. A type is considered an iterable of entities if it is an array or implementsIterableand its element type is an entity of the given type.- Parameters:
type- The type to check. May be null.entityType- The expected entity type. Must not be null.- Returns:
- true if the type is an iterable of entities of the given type, false otherwise.
-
isDto
public static boolean isDto(@Nullable io.micronaut.inject.ast.ClassElement type) Does the given type have anIntrospected.- Parameters:
type- The type- Returns:
- True if it does
-
hasPersistedTypeArgument
public static boolean hasPersistedTypeArgument(@Nullable io.micronaut.inject.ast.ClassElement type) Does the given type have a first argument annotated withMappedEntity.- Parameters:
type- The type- Returns:
- True if it does
-
doesMethodProducesANumber
public static boolean doesMethodProducesANumber(io.micronaut.inject.ast.MethodElement methodElement) Does the method return an object convertible to a number.- Parameters:
methodElement- The method element- Returns:
- True if it does
-
doesReturnVoid
public static boolean doesReturnVoid(io.micronaut.inject.ast.MethodElement methodElement) Does the method element return void.- Parameters:
methodElement- The method element- Returns:
- True if it returns void
-
getMethodProducingItemType
public static @Nullable io.micronaut.inject.ast.ClassElement getMethodProducingItemType(io.micronaut.inject.ast.MethodElement methodElement) -
doesMethodProducesABoolean
public static boolean doesMethodProducesABoolean(io.micronaut.inject.ast.MethodElement methodElement) Does the given method element return boolean.- Parameters:
methodElement- The method element- Returns:
- True if it does
-
isContainerType
public static boolean isContainerType(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a container type such as a collection etc.- Parameters:
type- The type- Returns:
- True if is
-
isReactiveType
public static boolean isReactiveType(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a reactive type.- Parameters:
type- The type- Returns:
- True if is
-
isFutureType
public static boolean isFutureType(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a future type.- Parameters:
type- The type- Returns:
- True if is
-
isReactiveOrFuture
public static boolean isReactiveOrFuture(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a future type.- Parameters:
type- The type- Returns:
- True if is
-
isReactiveSingleResult
public static boolean isReactiveSingleResult(@Nullable io.micronaut.inject.ast.ClassElement type) Is the reactive type a single-result type, i.e. emits at most one item.A reactive type is considered single-result if it meets any of the following conditions:
- has the
SingleResultstereotype - is
reactor.core.publisher.Mono - is
io.reactivex.rxjava3.core.Single
- Parameters:
type- The type- Returns:
- True if is a single-result reactive type
- has the
-
isNumber
public static boolean isNumber(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a number.- Parameters:
type- The type- Returns:
- True if is a number
-
isComparable
public static boolean isComparable(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a number.- Parameters:
type- The type- Returns:
- True if is a number
-
isPeriod
public static boolean isPeriod(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a period.- Parameters:
type- The type- Returns:
- True if is a period
- Since:
- 5.0
-
isTextual
public static boolean isTextual(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a string.- Parameters:
type- The type- Returns:
- True if is a number
-
isVoid
public static boolean isVoid(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type void.- Parameters:
type- The type- Returns:
- True if is void
-
isBoolean
public static boolean isBoolean(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a boolean.- Parameters:
type- The type- Returns:
- True if is a boolean
-
isValidBatchUpdateReturnType
public static boolean isValidBatchUpdateReturnType(io.micronaut.inject.ast.MethodElement methodElement) Returns true if the return type is considered valid for batch update operations likes deletes and updates.- Parameters:
methodElement- The method element- Returns:
- True if is valid
-
isValidCountReturnType
Checks whether the return type is supported.- Parameters:
matchContext- The match context- Returns:
- True if it is supported
-
doesMethodProducesIterableOfAnEntityOrDto
public static boolean doesMethodProducesIterableOfAnEntityOrDto(io.micronaut.inject.ast.MethodElement methodElement) Checks whether the return type is supported.- Parameters:
methodElement- The method- Returns:
- True if it is supported
-
doesMethodProducesIterable
public static boolean doesMethodProducesIterable(io.micronaut.inject.ast.MethodElement methodElement) Checks whether the return type is supported.- Parameters:
methodElement- The method- Returns:
- True if it is supported
-
doesMethodProducesAnEntityIterableOfAnEntity
public static boolean doesMethodProducesAnEntityIterableOfAnEntity(io.micronaut.inject.ast.MethodElement methodElement) Checks whether the return type is supported.- Parameters:
methodElement- The method- Returns:
- True if it is supported
-
isObjectClass
public static boolean isObjectClass(io.micronaut.inject.ast.ClassElement type) Whether the given type is Object.- Parameters:
type- The type- Returns:
- True if it is Object
-
resolveDataType
-
resolveDataConverter
-
resolveDataType
-
areTypesCompatible
public static boolean areTypesCompatible(io.micronaut.inject.ast.ClassElement leftType, io.micronaut.inject.ast.ClassElement rightType) Return true if the left type is compatible or can be assigned to the right type.- Parameters:
leftType- The left typerightType- The right type- Returns:
- True if they are
-
getTypeName
Return the type for the given class element, wrapping primitives types if necessary.- Parameters:
type- The type- Returns:
- The ID type
-