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(@NonNull 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(@NonNull io.micronaut.inject.ast.MethodElement methodElement) Does the method return an object convertible to a number.static booleandoesMethodProducesIterableOfAnEntityOrDto(io.micronaut.inject.ast.MethodElement methodElement) Checks whether the return type is supported.static booleandoesReturnVoid(@NonNull io.micronaut.inject.ast.MethodElement methodElement) Does the method element return void.static @Nullable io.micronaut.inject.ast.ClassElementgetKotlinCoroutineProducedType(@NonNull io.micronaut.inject.ast.MethodElement methodElement) static @Nullable io.micronaut.inject.ast.ClassElementgetMethodProducingItemType(@NonNull io.micronaut.inject.ast.MethodElement methodElement) static @NonNull StringgetTypeName(@NonNull 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 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 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 booleanisReactiveOrFuture(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a future type.static booleanisReactiveType(@Nullable io.micronaut.inject.ast.ClassElement type) Is the type a reactive type.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(@NonNull io.micronaut.inject.ast.ClassElement type, Map<String, String> dataConverters) Resolve the converter for the given type.static @NonNull DataTyperesolveDataType(@NonNull io.micronaut.inject.ast.ClassElement type, Map<String, DataType> dataTypes) Compute the data type for the given type.resolveDataType(@NonNull io.micronaut.inject.ast.ParameterElement parameter) Compute the data type for the given parameter.
-
Constructor Details
-
TypeUtils
public TypeUtils()
-
-
Method Details
-
getKotlinCoroutineProducedType
@Nullable public static @Nullable io.micronaut.inject.ast.ClassElement getKotlinCoroutineProducedType(@NonNull @NonNull io.micronaut.inject.ast.MethodElement methodElement) -
isIterableOfEntity
public static boolean isIterableOfEntity(@Nullable @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 @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 @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 @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 @Nullable io.micronaut.inject.ast.ClassElement type) Does the given type have anMappedEntity.- Parameters:
type- The type- Returns:
- True if it does
-
isDto
public static boolean isDto(@Nullable @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 @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(@NonNull @NonNull 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(@NonNull @NonNull io.micronaut.inject.ast.MethodElement methodElement) Does the method element return void.- Parameters:
methodElement- The method element- Returns:
- True if it returns void
-
getMethodProducingItemType
@Nullable public static @Nullable io.micronaut.inject.ast.ClassElement getMethodProducingItemType(@NonNull @NonNull io.micronaut.inject.ast.MethodElement methodElement) -
doesMethodProducesABoolean
public static boolean doesMethodProducesABoolean(@NonNull @NonNull 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 @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 @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 @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 @Nullable io.micronaut.inject.ast.ClassElement type) Is the type a future type.- Parameters:
type- The type- Returns:
- True if is
-
isNumber
public static boolean isNumber(@Nullable @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 @Nullable io.micronaut.inject.ast.ClassElement type) Is the type a number.- Parameters:
type- The type- Returns:
- True if is a number
-
isVoid
public static boolean isVoid(@Nullable @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 @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
-
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
public static Optional<DataType> resolveDataType(@NonNull @NonNull io.micronaut.inject.ast.ParameterElement parameter) Compute the data type for the given parameter.- Parameters:
parameter- The parameter- Returns:
- The data type
-
resolveDataConverter
@Nullable public static @Nullable String resolveDataConverter(@NonNull @NonNull io.micronaut.inject.ast.ClassElement type, Map<String, String> dataConverters) Resolve the converter for the given type.- Parameters:
type- The typedataConverters- Configured data converters- Returns:
- The data type
-
resolveDataType
@NonNull public static @NonNull DataType resolveDataType(@NonNull @NonNull io.micronaut.inject.ast.ClassElement type, Map<String, DataType> dataTypes) Compute the data type for the given type.- Parameters:
type- The typedataTypes- Configured data types- Returns:
- The data type
-
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
@NonNull public static @NonNull String getTypeName(@NonNull @NonNull io.micronaut.inject.ast.ClassElement type) Return the type for the given class element, wrapping primitives types if necessary.- Parameters:
type- The type- Returns:
- The ID type
-