java.lang.Object
io.micronaut.data.processor.visitors.finders.TypeUtils

@Internal public class TypeUtils extends Object
Internal utility methods.
Since:
1.0.0
Author:
graemerocher
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    static boolean
    doesMethodProducesABoolean(@NonNull io.micronaut.inject.ast.MethodElement methodElement)
    Does the given method element return boolean.
    static boolean
    doesMethodProducesAnEntityIterableOfAnEntity(io.micronaut.inject.ast.MethodElement methodElement)
    Checks whether the return type is supported.
    static boolean
    doesMethodProducesANumber(@NonNull io.micronaut.inject.ast.MethodElement methodElement)
    Does the method return an object convertible to a number.
    static boolean
    doesMethodProducesIterable(io.micronaut.inject.ast.MethodElement methodElement)
    Checks whether the return type is supported.
    static boolean
    doesMethodProducesIterableOfAnEntityOrDto(io.micronaut.inject.ast.MethodElement methodElement)
    Checks whether the return type is supported.
    static boolean
    doesReturnVoid(@NonNull io.micronaut.inject.ast.MethodElement methodElement)
    Does the method element return void.
    static @Nullable io.micronaut.inject.ast.ClassElement
    getKotlinCoroutineProducedType(@NonNull io.micronaut.inject.ast.MethodElement methodElement)
     
    static @Nullable io.micronaut.inject.ast.ClassElement
    getMethodProducingItemType(@NonNull io.micronaut.inject.ast.MethodElement methodElement)
     
    static @NonNull String
    getTypeName(@NonNull io.micronaut.inject.ast.ClassElement type)
    Return the type for the given class element, wrapping primitives types if necessary.
    static boolean
    hasPersistedTypeArgument(@Nullable io.micronaut.inject.ast.ClassElement type)
    Does the given type have a first argument annotated with MappedEntity.
    static boolean
    isBoolean(@Nullable io.micronaut.inject.ast.ClassElement type)
    Is the type a boolean.
    static boolean
    isComparable(@Nullable io.micronaut.inject.ast.ClassElement type)
    Is the type a number.
    static boolean
    isContainerType(@Nullable io.micronaut.inject.ast.ClassElement type)
    Is the type a container type such as a collection etc.
    static boolean
    isDto(@Nullable io.micronaut.inject.ast.ClassElement type)
    Does the given type have an Introspected.
    static boolean
    isEntity(@Nullable io.micronaut.inject.ast.ClassElement type)
    Does the given type have an MappedEntity.
    static boolean
    isEntityContainerType(@Nullable io.micronaut.inject.ast.ClassElement type)
    Is the given type a container type of entity.
    static boolean
    isEntityOrDto(@Nullable io.micronaut.inject.ast.ClassElement type)
    Does the given type have an MappedEntity or Introspected.
    static boolean
    isFutureType(@Nullable io.micronaut.inject.ast.ClassElement type)
    Is the type a future type.
    static boolean
    isIterableOfDto(@Nullable io.micronaut.inject.ast.ClassElement type)
    Is the element an iterable of a DTO.
    static boolean
    isIterableOfEntity(@Nullable io.micronaut.inject.ast.ClassElement type)
    Is the element an iterable of an entity.
    static boolean
    isNumber(@Nullable io.micronaut.inject.ast.ClassElement type)
    Is the type a number.
    static boolean
    isObjectClass(io.micronaut.inject.ast.ClassElement type)
    Whether the given type is Object.
    static boolean
    isReactiveOrFuture(@Nullable io.micronaut.inject.ast.ClassElement type)
    Is the type a future type.
    static boolean
    isReactiveType(@Nullable io.micronaut.inject.ast.ClassElement type)
    Is the type a reactive type.
    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.
    static boolean
    Checks whether the return type is supported.
    static boolean
    isVoid(@Nullable io.micronaut.inject.ast.ClassElement type)
    Is the type void.
    static @Nullable String
    resolveDataConverter(@NonNull io.micronaut.inject.ast.ClassElement type, Map<String,String> dataConverters)
    Resolve the converter for the given type.
    static @NonNull DataType
    resolveDataType(@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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 an MappedEntity or Introspected.
      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 an MappedEntity.
      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 an Introspected.
      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 with MappedEntity.
      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

      public static boolean isValidCountReturnType(MatchContext matchContext)
      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

      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 type
      dataConverters - 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 type
      dataTypes - 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 type
      rightType - 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