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, javax.annotation.processing.ProcessingEnvironment env, java.lang.Class<?> generatorClass)static voidaddGeneratedAnnotation(com.squareup.javapoet.TypeSpec.Builder typeSpecBuilder, javax.annotation.processing.ProcessingEnvironment 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 voidcheckForCompilationError(javax.lang.model.element.TypeElement e)Checks that the given element is not the error type.static com.google.common.collect.ImmutableMap<java.lang.String,javax.lang.model.element.AnnotationValue>convertToAttributeNameMap(java.util.Map<? extends javax.lang.model.element.ExecutableElement,? extends javax.lang.model.element.AnnotationValue> annotationValues)Converts an annotation value map to be keyed by the attribute name.static com.squareup.javapoet.MethodSpec.BuildercopyMethodSpecWithoutBody(com.squareup.javapoet.MethodSpec methodSpec)static voidgenerateAggregatingClass(java.lang.String aggregatingPackage, com.squareup.javapoet.AnnotationSpec aggregatingAnnotation, javax.lang.model.element.TypeElement element, java.lang.Class<?> generatedAnnotationClass, javax.annotation.processing.ProcessingEnvironment env)static com.google.common.collect.ImmutableList<javax.lang.model.element.ExecutableElement>getAllMethods(javax.lang.model.element.TypeElement element)Returns all transitive methods from a given TypeElement, not including constructors.static com.google.common.collect.Multimap<java.lang.String,javax.lang.model.element.AnnotationMirror>getAnnotationAnnotationArrayValues(javax.lang.model.util.Elements elements, javax.lang.model.element.AnnotationMirror annotation)Returns a multimap from attribute name to the values that are an array of annotation mirrors.static javax.lang.model.element.TypeElementgetAnnotationClassValue(javax.lang.model.util.Elements elements, javax.lang.model.element.AnnotationMirror annotation, java.lang.String key)Returns theTypeElementfor a class attribute on an annotation.static com.google.common.collect.ImmutableList<javax.lang.model.element.TypeElement>getAnnotationClassValues(javax.lang.model.util.Elements elements, javax.lang.model.element.AnnotationMirror annotation, java.lang.String key)Returns a list ofTypeElements for a class attribute on an annotation.static javax.lang.model.element.AnnotationMirrorgetAnnotationMirror(javax.lang.model.element.Element element, com.squareup.javapoet.ClassName className)Returns the annotation mirror from the given element that corresponds to the given class.static javax.lang.model.element.AnnotationMirrorgetAnnotationMirror(javax.lang.model.element.Element element, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)static com.google.common.collect.ImmutableList<javax.lang.model.element.AnnotationMirror>getAnnotationsAnnotatedWith(javax.lang.model.element.Element element, com.squareup.javapoet.ClassName subAnnotation)Returns annotations of element that are annotated with subAnnotationstatic com.google.common.collect.ImmutableMap<java.lang.String,javax.lang.model.element.AnnotationValue>getAnnotationValues(javax.lang.model.util.Elements elements, javax.lang.model.element.AnnotationMirror annotation)Returns a map fromAnnotationMirrorattribute name toAnnotationValuesstatic java.lang.BooleangetBooleanAnnotationValue(javax.lang.model.element.AnnotationValue value)Gets the values from an annotation value representing an int.static com.google.common.collect.ImmutableList<javax.lang.model.element.ExecutableElement>getConstructors(javax.lang.model.element.TypeElement element)static javax.lang.model.type.DeclaredTypegetDeclaredType(javax.lang.model.type.TypeMirror type)Returns the declared type if the received mirror represents a declared type or an array of declared types, otherwise throws anIllegalStateException.static javax.lang.model.type.DeclaredTypegetDeclaredTypeAnnotationValue(javax.lang.model.element.AnnotationValue value)Gets the values from an annotation value representing a DeclaredType.static com.google.common.collect.ImmutableSet<javax.lang.model.element.Element>getElementsAnnotatedWith(javax.annotation.processing.RoundEnvironment roundEnv, java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)Returns all elements in the round that are annotated with at least 1 of the given annotations.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 com.squareup.javapoet.ClassNamegetEnclosedClassName(javax.lang.model.element.TypeElement typeElement)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.StringgetEnclosedName(javax.lang.model.element.TypeElement element)Returns the name of a class.static com.google.common.collect.ImmutableSet<javax.lang.model.element.VariableElement>getEnumArrayAnnotationValue(javax.lang.model.element.AnnotationValue value)Gets the values from an annotation value representing a Enum array.static java.lang.StringgetFullEnclosedName(javax.lang.model.element.Element element)Returns the fully qualified class name, with _ instead of .static java.lang.StringgetFullyQualifiedEnclosedClassName(com.squareup.javapoet.ClassName className)Returns the fully qualified class name, with _ instead of .static java.lang.IntegergetIntAnnotationValue(javax.lang.model.element.AnnotationValue value)Gets the values from an annotation value representing an int.static java.lang.LonggetLongAnnotationValue(javax.lang.model.element.AnnotationValue value)Gets the values from an annotation value representing a long.static com.google.common.collect.ImmutableList<javax.lang.model.element.AnnotationMirror>getMapKeyAnnotations(javax.lang.model.element.Element element)Returns MapKey annotated annotations found on an element.static com.google.common.collect.ImmutableList<javax.lang.model.element.ExecutableElement>getMethods(javax.lang.model.element.TypeElement element)Returns methods from a given TypeElement, not including constructors.static java.util.Optional<javax.lang.model.element.TypeElement>getOptionalAnnotationClassValue(javax.lang.model.util.Elements elements, javax.lang.model.element.AnnotationMirror annotation, java.lang.String key)Returns an optionalTypeElementfor a class attribute on an annotation.static com.google.common.collect.ImmutableList<javax.lang.model.element.TypeElement>getOptionalAnnotationClassValues(javax.lang.model.util.Elements elements, javax.lang.model.element.AnnotationMirror annotation, java.lang.String key)Returns a list ofTypeElements for a class attribute on an annotation.static java.util.Optional<javax.lang.model.type.DeclaredType>getOptionalDeclaredType(javax.lang.model.type.TypeMirror type)Returns anOptional.of(T)the declared type if the received mirror represents a declared type or an array of declared types, otherwise returnsOptional.empty().static com.squareup.javapoet.AnnotationSpecgetOriginatingElementAnnotation(javax.lang.model.element.TypeElement element)static java.util.Optional<javax.lang.model.element.TypeElement>getOriginatingTestElement(javax.lang.model.element.Element element, javax.lang.model.util.Elements elements)static javax.lang.model.element.PackageElementgetPackageElement(javax.lang.model.element.Element originalElement)Returns the given elements containing package element.static javax.lang.model.type.PrimitiveTypegetPrimitiveType(javax.lang.model.type.TypeMirror type)If the received mirror represents a primitive type or an array of primitive types, this returns the represented primitive type.static com.google.common.collect.ImmutableList<javax.lang.model.element.AnnotationMirror>getQualifierAnnotations(javax.lang.model.element.Element element)Returns Qualifier annotated annotations found on an element.static com.google.common.collect.ImmutableList<javax.lang.model.element.AnnotationMirror>getScopeAnnotations(javax.lang.model.element.Element element)Returns Scope annotated annotations found on an element.static java.lang.StringgetStringAnnotationValue(javax.lang.model.element.AnnotationValue value)Gets the values from an annotation value representing a string.static com.google.common.collect.ImmutableList<java.lang.String>getStringArrayAnnotationValue(javax.lang.model.element.AnnotationValue value)Gets the values from an annotation value representing a string array.static javax.lang.model.element.TypeElementgetTopLevelType(javax.lang.model.element.Element originalElement)static booleanhasAnnotation(javax.lang.model.element.AnnotationMirror mirror, com.squareup.javapoet.ClassName className)Returns true if the given element has an annotation with the given class name.static booleanhasAnnotation(javax.lang.model.element.AnnotationMirror mirror, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)Returns true if the given element is annotated with the given annotation.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 booleanhasAnnotation(javax.lang.model.element.Element element, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)Returns true if the given element is annotated with the given annotation.static booleanhasAnnotationsAnnotatedWith(javax.lang.model.element.Element element, com.squareup.javapoet.ClassName subAnnotation)Returns true if there are any annotations of element that are annotated with subAnnotationstatic booleanhasDaggerAbstractMethodAnnotation(javax.lang.model.element.ExecutableElement method)Returns true if the given method is annotated with one of the annotations Dagger recognizes for abstract methods (e.g.static booleanhasErrorTypeAnnotation(javax.lang.model.element.Element element)Returns true if the given element has an annotation that is an error kind.static booleanhasVisibleEmptyConstructor(javax.lang.model.element.TypeElement type)static booleanisAssignableFrom(javax.lang.model.element.TypeElement element, com.squareup.javapoet.ClassName className)static booleanisAssignableFromAnyOf(javax.lang.model.element.TypeElement element, com.google.common.collect.ImmutableSet<com.squareup.javapoet.ClassName> classNames)static booleanisObjectMethod(javax.lang.model.element.ExecutableElement method)Returns true iff the givenmethodis one of the public or protected methods onObject, or an overridden version thereof.static booleanisTopLevel(javax.lang.model.element.Element element)Returns true if the given element is a top-level element.static com.google.common.collect.ImmutableList<javax.lang.model.element.ExecutableElement>methodsOnInterfaces(javax.lang.model.element.TypeElement type)Finds methods of interfaces implemented bytype.static com.squareup.javapoet.ParameterSpecparameterSpecFromVariableElement(javax.lang.model.element.VariableElement 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.MethodSpecprivateEmptyConstructor()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(javax.lang.model.element.TypeElement type, java.lang.String suffix)Removes the stringsuffixfrom the simple name oftypeand returns it.static booleanrequiresModuleInstance(javax.lang.model.util.Elements elements, javax.lang.model.element.TypeElement module)static com.google.common.collect.ImmutableSet<com.squareup.javapoet.ClassName>toClassNames(java.lang.Iterable<javax.lang.model.element.TypeElement> elements)static com.google.common.collect.ImmutableSet<javax.lang.model.element.TypeElement>toTypeElements(javax.lang.model.util.Elements elements, java.lang.String[] classes)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, javax.lang.model.element.TypeElement element, java.lang.Class<?> generatedAnnotationClass, javax.annotation.processing.ProcessingEnvironment env) throws java.io.IOException- Throws:
java.io.IOException
-
getAnnotationValues
public static com.google.common.collect.ImmutableMap<java.lang.String,javax.lang.model.element.AnnotationValue> getAnnotationValues(javax.lang.model.util.Elements elements, javax.lang.model.element.AnnotationMirror annotation)Returns a map fromAnnotationMirrorattribute name toAnnotationValues
-
getAnnotationAnnotationArrayValues
public static com.google.common.collect.Multimap<java.lang.String,javax.lang.model.element.AnnotationMirror> getAnnotationAnnotationArrayValues(javax.lang.model.util.Elements elements, javax.lang.model.element.AnnotationMirror annotation)Returns a multimap from attribute name to the values that are an array of annotation mirrors. The returned map will not contain mappings for any attributes that are not Annotation Arrays.e.g. if the input was the annotation mirror for
@Foo({@Bar("hello"), @Bar("world")})the map returned would have "value" map to a set containing the two @Bar annotation mirrors.
-
getAnnotationClassValue
public static javax.lang.model.element.TypeElement getAnnotationClassValue(javax.lang.model.util.Elements elements, javax.lang.model.element.AnnotationMirror annotation, java.lang.String key)Returns theTypeElementfor a class attribute on an annotation.
-
getAnnotationClassValues
public static com.google.common.collect.ImmutableList<javax.lang.model.element.TypeElement> getAnnotationClassValues(javax.lang.model.util.Elements elements, javax.lang.model.element.AnnotationMirror annotation, java.lang.String key)Returns a list ofTypeElements for a class attribute on an annotation.
-
getOptionalAnnotationClassValue
public static java.util.Optional<javax.lang.model.element.TypeElement> getOptionalAnnotationClassValue(javax.lang.model.util.Elements elements, javax.lang.model.element.AnnotationMirror annotation, java.lang.String key)Returns an optionalTypeElementfor a class attribute on an annotation.
-
getOptionalAnnotationClassValues
public static com.google.common.collect.ImmutableList<javax.lang.model.element.TypeElement> getOptionalAnnotationClassValues(javax.lang.model.util.Elements elements, javax.lang.model.element.AnnotationMirror annotation, java.lang.String key)Returns a list ofTypeElements for a class attribute on an annotation.
-
getPrimitiveType
public static javax.lang.model.type.PrimitiveType getPrimitiveType(javax.lang.model.type.TypeMirror type)
If the received mirror represents a primitive type or an array of primitive types, this returns the represented primitive type. Otherwise throws an IllegalStateException.
-
getOptionalDeclaredType
public static java.util.Optional<javax.lang.model.type.DeclaredType> getOptionalDeclaredType(javax.lang.model.type.TypeMirror type)
Returns anOptional.of(T)the declared type if the received mirror represents a declared type or an array of declared types, otherwise returnsOptional.empty().
-
getDeclaredType
public static javax.lang.model.type.DeclaredType getDeclaredType(javax.lang.model.type.TypeMirror type)
Returns the declared type if the received mirror represents a declared type or an array of declared types, otherwise throws anIllegalStateException.
-
getStringArrayAnnotationValue
public static com.google.common.collect.ImmutableList<java.lang.String> getStringArrayAnnotationValue(javax.lang.model.element.AnnotationValue value)
Gets the values from an annotation value representing a string array.
-
getBooleanAnnotationValue
public static java.lang.Boolean getBooleanAnnotationValue(javax.lang.model.element.AnnotationValue value)
Gets the values from an annotation value representing an int.
-
getIntAnnotationValue
public static java.lang.Integer getIntAnnotationValue(javax.lang.model.element.AnnotationValue value)
Gets the values from an annotation value representing an int.
-
getLongAnnotationValue
public static java.lang.Long getLongAnnotationValue(javax.lang.model.element.AnnotationValue value)
Gets the values from an annotation value representing a long.
-
getStringAnnotationValue
public static java.lang.String getStringAnnotationValue(javax.lang.model.element.AnnotationValue value)
Gets the values from an annotation value representing a string.
-
getDeclaredTypeAnnotationValue
public static javax.lang.model.type.DeclaredType getDeclaredTypeAnnotationValue(javax.lang.model.element.AnnotationValue value)
Gets the values from an annotation value representing a DeclaredType.
-
getEnumArrayAnnotationValue
public static com.google.common.collect.ImmutableSet<javax.lang.model.element.VariableElement> getEnumArrayAnnotationValue(javax.lang.model.element.AnnotationValue value)
Gets the values from an annotation value representing a Enum array.
-
convertToAttributeNameMap
public static com.google.common.collect.ImmutableMap<java.lang.String,javax.lang.model.element.AnnotationValue> convertToAttributeNameMap(java.util.Map<? extends javax.lang.model.element.ExecutableElement,? extends javax.lang.model.element.AnnotationValue> annotationValues)
Converts an annotation value map to be keyed by the attribute name.
-
getPackageElement
public static javax.lang.model.element.PackageElement getPackageElement(javax.lang.model.element.Element originalElement)
Returns the given elements containing package element.
-
getTopLevelType
public static javax.lang.model.element.TypeElement getTopLevelType(javax.lang.model.element.Element originalElement)
-
isTopLevel
public static boolean isTopLevel(javax.lang.model.element.Element element)
Returns true if the given element is a top-level element.
-
hasAnnotation
public static boolean hasAnnotation(javax.lang.model.element.Element element, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)Returns true if the given element is annotated with the given annotation.
-
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.
-
hasAnnotation
public static boolean hasAnnotation(javax.lang.model.element.AnnotationMirror mirror, com.squareup.javapoet.ClassName className)Returns true if the given element has an annotation with the given class name.
-
hasAnnotation
public static boolean hasAnnotation(javax.lang.model.element.AnnotationMirror mirror, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)Returns true if the given element is annotated with the given annotation.
-
hasErrorTypeAnnotation
public static boolean hasErrorTypeAnnotation(javax.lang.model.element.Element element)
Returns true if the given element has an annotation that is an error kind.
-
getElementsAnnotatedWith
@SafeVarargs public static com.google.common.collect.ImmutableSet<javax.lang.model.element.Element> getElementsAnnotatedWith(javax.annotation.processing.RoundEnvironment roundEnv, java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)Returns all elements in the round that are annotated with at least 1 of the given annotations.
-
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
-
getEnclosedName
public static java.lang.String getEnclosedName(javax.lang.model.element.TypeElement element)
Returns the name of a class. SeegetEnclosedName(ClassName).
-
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(javax.lang.model.element.TypeElement typeElement)
Returns an equivalent class name with the.(dots) used for inner classes replaced with_.
-
getFullyQualifiedEnclosedClassName
public static java.lang.String getFullyQualifiedEnclosedClassName(com.squareup.javapoet.ClassName className)
Returns the fully qualified class name, with _ instead of .
-
getFullEnclosedName
public static java.lang.String getFullEnclosedName(javax.lang.model.element.Element 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(javax.lang.model.element.TypeElement type, java.lang.String suffix)Removes the stringsuffixfrom the simple name oftypeand returns it.- Throws:
BadInputException- if the simple name oftypedoes not end withsuffix
-
getAnnotationMirror
public static javax.lang.model.element.AnnotationMirror getAnnotationMirror(javax.lang.model.element.Element element, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)- See Also:
getAnnotationMirror(Element, ClassName)
-
getAnnotationMirror
public static javax.lang.model.element.AnnotationMirror getAnnotationMirror(javax.lang.model.element.Element element, com.squareup.javapoet.ClassName className)Returns the annotation mirror from the given element that corresponds to the given class.- Throws:
java.lang.IllegalStateException- if the given element isn't annotated with that annotation.
-
isAssignableFrom
public static boolean isAssignableFrom(javax.lang.model.element.TypeElement element, com.squareup.javapoet.ClassName className)- Returns:
- true if element inherits directly or indirectly from the className
-
isAssignableFromAnyOf
public static boolean isAssignableFromAnyOf(javax.lang.model.element.TypeElement element, com.google.common.collect.ImmutableSet<com.squareup.javapoet.ClassName> classNames)- Returns:
- true if element inherits directly or indirectly from any of the classNames
-
getMethods
public static com.google.common.collect.ImmutableList<javax.lang.model.element.ExecutableElement> getMethods(javax.lang.model.element.TypeElement element)
Returns methods from a given TypeElement, not including constructors.
-
getConstructors
public static com.google.common.collect.ImmutableList<javax.lang.model.element.ExecutableElement> getConstructors(javax.lang.model.element.TypeElement element)
-
getAllMethods
public static com.google.common.collect.ImmutableList<javax.lang.model.element.ExecutableElement> getAllMethods(javax.lang.model.element.TypeElement element)
Returns all transitive methods from a given TypeElement, not including constructors. Also does not include methods from Object or that override methods on Object.
-
checkForCompilationError
public static void checkForCompilationError(javax.lang.model.element.TypeElement e)
Checks that the given element is not the error type.
-
methodsOnInterfaces
public static com.google.common.collect.ImmutableList<javax.lang.model.element.ExecutableElement> methodsOnInterfaces(javax.lang.model.element.TypeElement type)
Finds methods of interfaces implemented bytype. This method also checks the superinterfaces of those interfaces. This method does not check the interfaces of any superclass oftype.
-
getMapKeyAnnotations
public static com.google.common.collect.ImmutableList<javax.lang.model.element.AnnotationMirror> getMapKeyAnnotations(javax.lang.model.element.Element element)
Returns MapKey annotated annotations found on an element.
-
getQualifierAnnotations
public static com.google.common.collect.ImmutableList<javax.lang.model.element.AnnotationMirror> getQualifierAnnotations(javax.lang.model.element.Element element)
Returns Qualifier annotated annotations found on an element.
-
getScopeAnnotations
public static com.google.common.collect.ImmutableList<javax.lang.model.element.AnnotationMirror> getScopeAnnotations(javax.lang.model.element.Element element)
Returns Scope annotated annotations found on an element.
-
getAnnotationsAnnotatedWith
public static com.google.common.collect.ImmutableList<javax.lang.model.element.AnnotationMirror> getAnnotationsAnnotatedWith(javax.lang.model.element.Element element, com.squareup.javapoet.ClassName subAnnotation)Returns annotations of element that are annotated with subAnnotation
-
hasAnnotationsAnnotatedWith
public static boolean hasAnnotationsAnnotatedWith(javax.lang.model.element.Element element, com.squareup.javapoet.ClassName subAnnotation)Returns true if there are any annotations of element that are annotated with subAnnotation
-
isObjectMethod
public static boolean isObjectMethod(javax.lang.model.element.ExecutableElement method)
Returns true iff the givenmethodis one of the public or protected methods onObject, or an overridden version thereof.This method ignores the return type of the given method, but this is generally fine since two methods which only differ by their return type will cause a compiler error. (e.g. a non-static method with the signature
int equals(Object))
-
parameterSpecFromVariableElement
public static com.squareup.javapoet.ParameterSpec parameterSpecFromVariableElement(javax.lang.model.element.VariableElement 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
-
privateEmptyConstructor
public static com.squareup.javapoet.MethodSpec privateEmptyConstructor()
- Returns:
- A method spec for an empty constructor (useful for abstract Dagger modules).
-
hasDaggerAbstractMethodAnnotation
public static boolean hasDaggerAbstractMethodAnnotation(javax.lang.model.element.ExecutableElement method)
Returns true if the given method is annotated with one of the annotations Dagger recognizes for abstract methods (e.g. @Binds).
-
toTypeElements
public static com.google.common.collect.ImmutableSet<javax.lang.model.element.TypeElement> toTypeElements(javax.lang.model.util.Elements elements, java.lang.String[] classes)
-
toClassNames
public static com.google.common.collect.ImmutableSet<com.squareup.javapoet.ClassName> toClassNames(java.lang.Iterable<javax.lang.model.element.TypeElement> elements)
-
requiresModuleInstance
public static boolean requiresModuleInstance(javax.lang.model.util.Elements elements, javax.lang.model.element.TypeElement module)
-
hasVisibleEmptyConstructor
public static boolean hasVisibleEmptyConstructor(javax.lang.model.element.TypeElement type)
-
addGeneratedAnnotation
public static void addGeneratedAnnotation(com.squareup.javapoet.TypeSpec.Builder typeSpecBuilder, javax.annotation.processing.ProcessingEnvironment env, java.lang.Class<?> generatorClass)
-
addGeneratedAnnotation
public static void addGeneratedAnnotation(com.squareup.javapoet.TypeSpec.Builder typeSpecBuilder, javax.annotation.processing.ProcessingEnvironment env, java.lang.String generatorClass)
-
getOriginatingElementAnnotation
public static com.squareup.javapoet.AnnotationSpec getOriginatingElementAnnotation(javax.lang.model.element.TypeElement 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<javax.lang.model.element.TypeElement> getOriginatingTestElement(javax.lang.model.element.Element element, javax.lang.model.util.Elements elements)
-
-