Class TypeTools

All Implemented Interfaces:
TypeInfoCreatorProvider

public final class TypeTools extends BuilderTypeTools
Generically handles Pico generated artifact creation via APT.
  • Method Details

    • toFilePath

      public static String toFilePath(TypeName typeName)
      Converts the provided name to a type name path.
      Parameters:
      typeName - the type name to evaluate
      Returns:
      the file path expression where dots are translated to file separators
    • toFilePath

      public static String toFilePath(TypeName typeName, String fileType)
      Converts the provided name to a type name path.
      Parameters:
      typeName - the type name to evaluate
      fileType - the file type, typically ".java"
      Returns:
      the file path expression where dots are translated to file separators
    • createAnnotationAndValueListFromAnnotations

      @Deprecated public static List<AnnotationAndValue> createAnnotationAndValueListFromAnnotations(Annotation[] annotations)
      Deprecated.
      switch to use pure annotation processing instead of reflection
      Creates an instance from reflective access. Note that this approach will only have visibility to the RetentionPolicy.RUNTIME type annotations.
      Parameters:
      annotations - the annotations on the type, method, or parameters
      Returns:
      the new instance
    • createQualifierAndValueSet

      public static Set<QualifierAndValue> createQualifierAndValueSet(Element type)
      Creates a set of qualifiers given the owning element.
      Parameters:
      type - the element type (from anno processing)
      Returns:
      the set of qualifiers that the owning element has
    • createQualifierAndValueSet

      public static Set<QualifierAndValue> createQualifierAndValueSet(List<? extends AnnotationMirror> annoMirrors)
      Creates a set of qualifiers given the owning element's annotation type mirror.
      Parameters:
      annoMirrors - the annotation type mirrors (from anno processing)
      Returns:
      the set of qualifiers that the owning element has
    • createAnnotationAndValueSet

      public static Set<AnnotationAndValue> createAnnotationAndValueSet(Element type)
      Creates a set of annotations based using annotation processor.
      Parameters:
      type - the enclosing/owing type element
      Returns:
      the annotation value set
    • createAnnotationAndValueSet

      public static Set<AnnotationAndValue> createAnnotationAndValueSet(io.github.classgraph.AnnotationInfoList annotationInfoList)
      Creates a set of annotations given the owning element.
      Parameters:
      annotationInfoList - the list of annotations
      Returns:
      the annotation and value set
    • extractInjectionPointTypeInfo

      public static String extractInjectionPointTypeInfo(Element typeElement, AtomicReference<Boolean> isProviderWrapped, AtomicReference<Boolean> isListWrapped, AtomicReference<Boolean> isOptionalWrapped)
      Determines the meta parts making up InjectionPointInfo for annotation processing.
      Parameters:
      typeElement - the variable / element type
      isProviderWrapped - set to indicate that the ip is a provided type
      isListWrapped - set to indicate that the ip is a list type
      isOptionalWrapped - set to indicate that the ip is an optional type
      Returns:
      the return type of the injection point
      Throws:
      IllegalStateException - thrown if internal state inconsistencies are found
    • isProviderType

      public static boolean isProviderType(String typeName)
      Determines whether the type is a Provider (or javax equiv) type.
      Parameters:
      typeName - the type name to check
      Returns:
      true if Provider or InjectionPointProvider
    • oppositeOf

      public static String oppositeOf(String typeName)
      Transposes "jakarta." from and/or to "javax.".
      Parameters:
      typeName - the type name to transpose
      Returns:
      the transposed value, or the same if not able to be transposed
    • isStatic

      public static boolean isStatic(Element element)
      Returns true if the element is static.
      Parameters:
      element - the element
      Returns:
      true if static
    • isAbstract

      public static boolean isAbstract(Element element)
      Returns true if the element is abstract.
      Parameters:
      element - the element
      Returns:
      true if abstract
    • toAccess

      public static ElementInfo.Access toAccess(Element element)
      Determines the access from an Element (from anno processing).
      Parameters:
      element - the element
      Returns:
      the access
    • needToDeclarePackageUsage

      public static boolean needToDeclarePackageUsage(String packageName)
      Checks whether the package name need to be declared.
      Parameters:
      packageName - the package name
      Returns:
      true if the package name needs to be declared
    • needToDeclareModuleUsage

      public static boolean needToDeclareModuleUsage(String moduleName)
      Checks whether the module name needs to be declared.
      Parameters:
      moduleName - the module name
      Returns:
      true if the module name needs to be declared