Package dagger.hilt.processor.internal
Class Processors
- java.lang.Object
-
- dagger.hilt.processor.internal.Processors
-
public final class Processors extends java.lang.ObjectStatic helper methods for writing a processor.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCONSTRUCTOR_NAMEstatic java.lang.StringSTATIC_INITIALIZER_NAME
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddGeneratedAnnotation(com.squareup.javapoet.TypeSpec.Builder typeSpecBuilder, androidx.room.compiler.processing.XProcessingEnv env, java.lang.Class<?> generatorClass)static voidaddGeneratedAnnotation(com.squareup.javapoet.TypeSpec.Builder typeSpecBuilder, androidx.room.compiler.processing.XProcessingEnv env, java.lang.String generatorClass)static com.squareup.javapoet.ClassNameappend(com.squareup.javapoet.ClassName name, java.lang.String suffix)Appends the given string to the end of the class name.static com.squareup.javapoet.MethodSpec.BuildercopyMethodSpecWithoutBody(com.squareup.javapoet.MethodSpec methodSpec)static voidgenerateAggregatingClass(java.lang.String aggregatingPackage, com.squareup.javapoet.AnnotationSpec aggregatingAnnotation, androidx.room.compiler.processing.XTypeElement originatingElement, java.lang.Class<?> generatorClass)Generates the aggregating metadata class for an aggregating annotation.static voidgenerateAggregatingClass(java.lang.String aggregatingPackage, com.squareup.javapoet.AnnotationSpec aggregatingAnnotation, androidx.room.compiler.processing.XTypeElement originatingElement, java.lang.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, java.lang.String key)Returns a list ofXTypeElements for a class attribute on an annotation.static com.google.common.collect.ImmutableMap<java.lang.String,androidx.room.compiler.processing.XAnnotationValue>getAnnotationValues(androidx.room.compiler.processing.XAnnotation annotation)Returns a map fromXAnnotationattribute name toXAnnotationValuesstatic com.squareup.javapoet.ClassNamegetEnclosedClassName(androidx.room.compiler.processing.XTypeElement typeElement)Returns an equivalent class name with the.(dots) used for inner classes replaced with_.static com.squareup.javapoet.ClassNamegetEnclosedClassName(com.squareup.javapoet.ClassName className)Returns an equivalent class name with the.(dots) used for inner classes replaced with_.static java.lang.StringgetEnclosedName(com.squareup.javapoet.ClassName name)Returns the name of a class, including prefixing with enclosing class names.static java.lang.StringgetFullEnclosedName(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, java.lang.String key)static com.squareup.javapoet.AnnotationSpecgetOriginatingElementAnnotation(androidx.room.compiler.processing.XTypeElement element)static java.util.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.XTypeElementgetTopLevelType(androidx.room.compiler.processing.XElement originalElement)static booleanhasAnnotation(javax.lang.model.element.Element element, com.squareup.javapoet.ClassName className)Returns true if the given element has an annotation with the given class name.static booleanhasDaggerAbstractMethodAnnotation(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 booleanhasErrorTypeAnnotation(androidx.room.compiler.processing.XElement element)Returns true if the given element has an annotation that is an error kind.static booleanhasJavaPackagePrivateVisibility(androidx.room.compiler.processing.XHasModifiers element)static booleanhasVisibleEmptyConstructor(androidx.room.compiler.processing.XTypeElement type)static booleanisAssignableFrom(androidx.room.compiler.processing.XTypeElement element, com.squareup.javapoet.ClassName className)Returnstrueif element inherits directly or indirectly from the className.static booleanisAssignableFromAnyOf(androidx.room.compiler.processing.XTypeElement element, com.google.common.collect.ImmutableSet<com.squareup.javapoet.ClassName> classNames)Returnstrueif element inherits directly or indirectly from any of the classNames.static booleanisTopLevel(androidx.room.compiler.processing.XElement element)static com.squareup.javapoet.ClassNameprepend(com.squareup.javapoet.ClassName name, java.lang.String prefix)Prepends the given string to the beginning of the class name.static com.squareup.javapoet.TypeNamerawTypeName(com.squareup.javapoet.TypeName typeName)Returns theTypeNamefor the raw type of the given type name.static com.squareup.javapoet.ClassNameremoveNameSuffix(androidx.room.compiler.processing.XTypeElement type, java.lang.String suffix)Removes the stringsuffixfrom the simple name oftypeand returns it.static booleanrequiresModuleInstance(androidx.room.compiler.processing.XTypeElement module)static java.lang.StringupperToLowerCamel(java.lang.String upperCamel)Shortcut for converting from upper camel to lower camel case
-
-
-
Field Detail
-
CONSTRUCTOR_NAME
public static final java.lang.String CONSTRUCTOR_NAME
- See Also:
- Constant Field Values
-
STATIC_INITIALIZER_NAME
public static final java.lang.String STATIC_INITIALIZER_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
generateAggregatingClass
public static void generateAggregatingClass(java.lang.String aggregatingPackage, com.squareup.javapoet.AnnotationSpec aggregatingAnnotation, androidx.room.compiler.processing.XTypeElement originatingElement, java.lang.Class<?> generatorClass)Generates the aggregating metadata class for an aggregating annotation.
-
generateAggregatingClass
public static void generateAggregatingClass(java.lang.String aggregatingPackage, com.squareup.javapoet.AnnotationSpec aggregatingAnnotation, androidx.room.compiler.processing.XTypeElement originatingElement, java.lang.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<java.lang.String,androidx.room.compiler.processing.XAnnotationValue> getAnnotationValues(androidx.room.compiler.processing.XAnnotation annotation)
Returns a map fromXAnnotationattribute name toXAnnotationValues
-
getAnnotationClassValues
public static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XTypeElement> getAnnotationClassValues(androidx.room.compiler.processing.XAnnotation annotation, java.lang.String key)Returns a list ofXTypeElements 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, java.lang.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(javax.lang.model.element.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 java.lang.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 java.lang.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, java.lang.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, java.lang.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, java.lang.String suffix)Removes the stringsuffixfrom the simple name oftypeand returns it.- Throws:
BadInputException- if the simple name oftypedoes not end withsuffix
-
isAssignableFrom
public static boolean isAssignableFrom(androidx.room.compiler.processing.XTypeElement element, com.squareup.javapoet.ClassName className)Returnstrueif 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)Returnstrueif 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.
-
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.
-
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 java.lang.String upperToLowerCamel(java.lang.String upperCamel)
Shortcut for converting from upper camel to lower camel caseExample: "SomeString" => "someString"
-
copyMethodSpecWithoutBody
public static com.squareup.javapoet.MethodSpec.Builder copyMethodSpecWithoutBody(com.squareup.javapoet.MethodSpec methodSpec)
- Returns:
- copy of the given MethodSpec as
MethodSpec.Builderwith 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, java.lang.Class<?> generatorClass)
-
addGeneratedAnnotation
public static void addGeneratedAnnotation(com.squareup.javapoet.TypeSpec.Builder typeSpecBuilder, androidx.room.compiler.processing.XProcessingEnv env, java.lang.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 theTypeNamefor the raw type of the given type name. If the argument isn't a parameterized type, it returns the argument unchanged.
-
getOriginatingTestElement
public static java.util.Optional<androidx.room.compiler.processing.XTypeElement> getOriginatingTestElement(androidx.room.compiler.processing.XElement element)
-
hasJavaPackagePrivateVisibility
public static boolean hasJavaPackagePrivateVisibility(androidx.room.compiler.processing.XHasModifiers element)
-
-