Class Processors

java.lang.Object
dagger.hilt.processor.internal.Processors

public final class Processors extends Object
Static helper methods for writing a processor.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addGeneratedAnnotation(com.squareup.javapoet.TypeSpec.Builder typeSpecBuilder, androidx.room.compiler.processing.XProcessingEnv env, Class<?> generatorClass)
     
    static void
    addGeneratedAnnotation(com.squareup.javapoet.TypeSpec.Builder typeSpecBuilder, androidx.room.compiler.processing.XProcessingEnv env, String generatorClass)
     
    static com.squareup.javapoet.ClassName
    append(com.squareup.javapoet.ClassName name, String suffix)
    Appends the given string to the end of the class name.
    static com.squareup.javapoet.MethodSpec.Builder
    copyMethodSpecWithoutBody(com.squareup.javapoet.MethodSpec methodSpec)
     
    static void
    generateAggregatingClass(String aggregatingPackage, com.squareup.javapoet.AnnotationSpec aggregatingAnnotation, androidx.room.compiler.processing.XTypeElement originatingElement, Class<?> generatorClass)
    Generates the aggregating metadata class for an aggregating annotation.
    static void
    generateAggregatingClass(String aggregatingPackage, com.squareup.javapoet.AnnotationSpec aggregatingAnnotation, androidx.room.compiler.processing.XTypeElement originatingElement, Class<?> generatorClass, androidx.room.compiler.processing.XFiler.Mode mode)
    Generates the aggregating metadata class for an aggregating annotation.
    static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XTypeElement>
    getAnnotationClassValues(androidx.room.compiler.processing.XAnnotation annotation, String key)
    Returns a list of XTypeElements for a class attribute on an annotation.
    static com.google.common.collect.ImmutableMap<String,androidx.room.compiler.processing.XAnnotationValue>
    getAnnotationValues(androidx.room.compiler.processing.XAnnotation annotation)
    Returns a map from XAnnotation attribute name to XAnnotationValues
    static com.squareup.javapoet.ClassName
    getEnclosedClassName(androidx.room.compiler.processing.XTypeElement typeElement)
    Returns an equivalent class name with the . (dots) used for inner classes replaced with _.
    static com.squareup.javapoet.ClassName
    getEnclosedClassName(com.squareup.javapoet.ClassName className)
    Returns an equivalent class name with the . (dots) used for inner classes replaced with _.
    static String
    getEnclosedName(com.squareup.javapoet.ClassName name)
    Returns the name of a class, including prefixing with enclosing class names.
    static String
    getFullEnclosedName(androidx.room.compiler.processing.XElement element)
    Returns the fully qualified class name, with _ instead of .
    static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XAnnotation>
    getMapKeyAnnotations(androidx.room.compiler.processing.XElement element)
    Returns MapKey annotated annotations found on an element.
    static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XTypeElement>
    getOptionalAnnotationClassValues(androidx.room.compiler.processing.XAnnotation annotation, String key)
     
    static com.squareup.javapoet.AnnotationSpec
    getOriginatingElementAnnotation(androidx.room.compiler.processing.XTypeElement element)
     
    static Optional<androidx.room.compiler.processing.XTypeElement>
    getOriginatingTestElement(androidx.room.compiler.processing.XElement element)
     
    static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XAnnotation>
    getQualifierAnnotations(androidx.room.compiler.processing.XElement element)
    Returns Qualifier annotated annotations found on an element.
    static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XAnnotation>
    getScopeAnnotations(androidx.room.compiler.processing.XElement element)
    Returns Scope annotated annotations found on an element.
    static androidx.room.compiler.processing.XTypeElement
    getTopLevelType(androidx.room.compiler.processing.XElement originalElement)
     
    static boolean
    hasAnnotation(Element element, com.squareup.javapoet.ClassName className)
    Returns true if the given element has an annotation with the given class name.
    static boolean
    hasDaggerAbstractMethodAnnotation(androidx.room.compiler.processing.XExecutableElement method)
    Returns true if the given method is annotated with one of the annotations Dagger recognizes for abstract methods (e.g.
    static boolean
    hasErrorTypeAnnotation(androidx.room.compiler.processing.XElement element)
    Returns true if the given element has an annotation that is an error kind.
    static boolean
    hasJavaPackagePrivateVisibility(androidx.room.compiler.processing.XHasModifiers element)
     
    static boolean
    hasVisibleEmptyConstructor(androidx.room.compiler.processing.XTypeElement type)
     
    static boolean
    isAnnotatedWithInject(androidx.room.compiler.processing.XElement element)
    Returns true if an element is annotated with @Inject.
    static boolean
    isAnnotatedWithScope(androidx.room.compiler.processing.XElement element)
    Returns true if an element is annotated with @Scope.
    static boolean
    isAssignableFrom(androidx.room.compiler.processing.XTypeElement element, com.squareup.javapoet.ClassName className)
    Returns true if element inherits directly or indirectly from the className.
    static boolean
    isAssignableFromAnyOf(androidx.room.compiler.processing.XTypeElement element, com.google.common.collect.ImmutableSet<com.squareup.javapoet.ClassName> classNames)
    Returns true if element inherits directly or indirectly from any of the classNames.
    static boolean
    isTopLevel(androidx.room.compiler.processing.XElement element)
     
    static com.squareup.javapoet.ClassName
    prepend(com.squareup.javapoet.ClassName name, String prefix)
    Prepends the given string to the beginning of the class name.
    static com.squareup.javapoet.TypeName
    rawTypeName(com.squareup.javapoet.TypeName typeName)
    Returns the TypeName for the raw type of the given type name.
    static com.squareup.javapoet.ClassName
    removeNameSuffix(androidx.room.compiler.processing.XTypeElement type, String suffix)
    Removes the string suffix from the simple name of type and returns it.
    static boolean
    requiresModuleInstance(androidx.room.compiler.processing.XTypeElement module)
     
    static String
    Shortcut for converting from upper camel to lower camel case

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • generateAggregatingClass

      public static void generateAggregatingClass(String aggregatingPackage, com.squareup.javapoet.AnnotationSpec aggregatingAnnotation, androidx.room.compiler.processing.XTypeElement originatingElement, Class<?> generatorClass)
      Generates the aggregating metadata class for an aggregating annotation.
    • generateAggregatingClass

      public static void generateAggregatingClass(String aggregatingPackage, com.squareup.javapoet.AnnotationSpec aggregatingAnnotation, androidx.room.compiler.processing.XTypeElement originatingElement, Class<?> generatorClass, androidx.room.compiler.processing.XFiler.Mode mode)
      Generates the aggregating metadata class for an aggregating annotation.
    • getAnnotationValues

      public static com.google.common.collect.ImmutableMap<String,androidx.room.compiler.processing.XAnnotationValue> getAnnotationValues(androidx.room.compiler.processing.XAnnotation annotation)
      Returns a map from XAnnotation attribute name to XAnnotationValues
    • getAnnotationClassValues

      public static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XTypeElement> getAnnotationClassValues(androidx.room.compiler.processing.XAnnotation annotation, String key)
      Returns a list of XTypeElements for a class attribute on an annotation.
    • getOptionalAnnotationClassValues

      public static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XTypeElement> getOptionalAnnotationClassValues(androidx.room.compiler.processing.XAnnotation annotation, String key)
    • getTopLevelType

      public static androidx.room.compiler.processing.XTypeElement getTopLevelType(androidx.room.compiler.processing.XElement originalElement)
    • isTopLevel

      public static boolean isTopLevel(androidx.room.compiler.processing.XElement element)
    • hasAnnotation

      public static boolean hasAnnotation(Element element, com.squareup.javapoet.ClassName className)
      Returns true if the given element has an annotation with the given class name.
    • hasErrorTypeAnnotation

      public static boolean hasErrorTypeAnnotation(androidx.room.compiler.processing.XElement element)
      Returns true if the given element has an annotation that is an error kind.
    • getEnclosedName

      public static String getEnclosedName(com.squareup.javapoet.ClassName name)
      Returns the name of a class, including prefixing with enclosing class names. i.e. for inner class Foo enclosed by Bar, returns Bar_Foo instead of just Foo
    • getEnclosedClassName

      public static com.squareup.javapoet.ClassName getEnclosedClassName(com.squareup.javapoet.ClassName className)
      Returns an equivalent class name with the . (dots) used for inner classes replaced with _.
    • getEnclosedClassName

      public static com.squareup.javapoet.ClassName getEnclosedClassName(androidx.room.compiler.processing.XTypeElement typeElement)
      Returns an equivalent class name with the . (dots) used for inner classes replaced with _.
    • getFullEnclosedName

      public static String getFullEnclosedName(androidx.room.compiler.processing.XElement element)
      Returns the fully qualified class name, with _ instead of . For elements that are not type elements, this continues to append the simple name of elements. For example, foo_bar_Outer_Inner_fooMethod.
    • append

      public static com.squareup.javapoet.ClassName append(com.squareup.javapoet.ClassName name, String suffix)
      Appends the given string to the end of the class name.
    • prepend

      public static com.squareup.javapoet.ClassName prepend(com.squareup.javapoet.ClassName name, String prefix)
      Prepends the given string to the beginning of the class name.
    • removeNameSuffix

      public static com.squareup.javapoet.ClassName removeNameSuffix(androidx.room.compiler.processing.XTypeElement type, String suffix)
      Removes the string suffix from the simple name of type and returns it.
      Throws:
      BadInputException - if the simple name of type does not end with suffix
    • isAssignableFrom

      public static boolean isAssignableFrom(androidx.room.compiler.processing.XTypeElement element, com.squareup.javapoet.ClassName className)
      Returns true if element inherits directly or indirectly from the className.
    • isAssignableFromAnyOf

      public static boolean isAssignableFromAnyOf(androidx.room.compiler.processing.XTypeElement element, com.google.common.collect.ImmutableSet<com.squareup.javapoet.ClassName> classNames)
      Returns true if element inherits directly or indirectly from any of the classNames.
    • getMapKeyAnnotations

      public static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XAnnotation> getMapKeyAnnotations(androidx.room.compiler.processing.XElement element)
      Returns MapKey annotated annotations found on an element.
    • isAnnotatedWithInject

      public static boolean isAnnotatedWithInject(androidx.room.compiler.processing.XElement element)
      Returns true if an element is annotated with @Inject.
    • getQualifierAnnotations

      public static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XAnnotation> getQualifierAnnotations(androidx.room.compiler.processing.XElement element)
      Returns Qualifier annotated annotations found on an element.
    • isAnnotatedWithScope

      public static boolean isAnnotatedWithScope(androidx.room.compiler.processing.XElement element)
      Returns true if an element is annotated with @Scope.
    • getScopeAnnotations

      public static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XAnnotation> getScopeAnnotations(androidx.room.compiler.processing.XElement element)
      Returns Scope annotated annotations found on an element.
    • upperToLowerCamel

      public static String upperToLowerCamel(String upperCamel)
      Shortcut for converting from upper camel to lower camel case

      Example: "SomeString" => "someString"

    • copyMethodSpecWithoutBody

      public static com.squareup.javapoet.MethodSpec.Builder copyMethodSpecWithoutBody(com.squareup.javapoet.MethodSpec methodSpec)
      Returns:
      copy of the given MethodSpec as MethodSpec.Builder with method body removed
    • hasDaggerAbstractMethodAnnotation

      public static boolean hasDaggerAbstractMethodAnnotation(androidx.room.compiler.processing.XExecutableElement method)
      Returns true if the given method is annotated with one of the annotations Dagger recognizes for abstract methods (e.g. @Binds).
    • requiresModuleInstance

      public static boolean requiresModuleInstance(androidx.room.compiler.processing.XTypeElement module)
    • hasVisibleEmptyConstructor

      public static boolean hasVisibleEmptyConstructor(androidx.room.compiler.processing.XTypeElement type)
    • addGeneratedAnnotation

      public static void addGeneratedAnnotation(com.squareup.javapoet.TypeSpec.Builder typeSpecBuilder, androidx.room.compiler.processing.XProcessingEnv env, Class<?> generatorClass)
    • addGeneratedAnnotation

      public static void addGeneratedAnnotation(com.squareup.javapoet.TypeSpec.Builder typeSpecBuilder, androidx.room.compiler.processing.XProcessingEnv env, String generatorClass)
    • getOriginatingElementAnnotation

      public static com.squareup.javapoet.AnnotationSpec getOriginatingElementAnnotation(androidx.room.compiler.processing.XTypeElement element)
    • rawTypeName

      public static com.squareup.javapoet.TypeName rawTypeName(com.squareup.javapoet.TypeName typeName)
      Returns the TypeName for the raw type of the given type name. If the argument isn't a parameterized type, it returns the argument unchanged.
    • getOriginatingTestElement

      public static Optional<androidx.room.compiler.processing.XTypeElement> getOriginatingTestElement(androidx.room.compiler.processing.XElement element)
    • hasJavaPackagePrivateVisibility

      public static boolean hasJavaPackagePrivateVisibility(androidx.room.compiler.processing.XHasModifiers element)