/** * Returns all of the {@link MapKey} annotations that annotate {@code bindingElement}. */ static ImmutableSet<? extends AnnotationMirror> getMapKeys(Element bindingElement) { return getAnnotatedAnnotations(bindingElement, MapKey.class); }
private static boolean typeIsOneOf(Set<Class<?>> classes, TypeMirror type) { for (Class<?> clazz : classes) { if (MoreTypes.isTypeOf(clazz, type)) { return true; } } return false; }
@Override public Optional<TypeElement> visitDeclared(DeclaredType t, Void p) { for (ModuleKind moduleKind : subcomponentKind.legalModuleKinds()) { if (isAnnotationPresent(t.asElement(), moduleKind.annotation())) { return Optional.of(MoreTypes.asTypeElement(t)); } } return Optional.empty(); } },
@Override public String format(ExecutableElement method) { return MethodSignatureFormatter.this.format( method, MoreTypes.asExecutable(types.asMemberOf(declaredType, method)), MoreElements.asType(method.getEnclosingElement())); } };
/** * Returns {@code true} iff the given element has an {@link AnnotationMirror} whose * {@linkplain AnnotationMirror#getAnnotationType() annotation type} has the same canonical name * as any of that of {@code annotationClasses}. */ static boolean isAnyAnnotationPresent( Element element, Iterable<? extends Class<? extends Annotation>> annotationClasses) { for (Class<? extends Annotation> annotation : annotationClasses) { if (MoreElements.isAnnotationPresent(element, annotation)) { return true; } } return false; }
@Override public Void visitDeclared(DeclaredType t, Set<TypeElement> p) { TypeElement typeElement = MoreTypes.asTypeElement(t); if (typeElement.getKind() == ElementKind.ANNOTATION_TYPE) { nestedAnnotationElements(typeElement, p); } return null; } };
@Override public DeclaredType getAnnotationType() { return MoreTypes.asDeclared(annotationType.asType()); }
ImmutableSet<ExecutableElement> getUnimplementedMethods(TypeElement type) { return FluentIterable.from(getLocalAndInheritedMethods(type, types, elements)) .filter(hasModifiers(ABSTRACT)) .toSet(); }
/** * Returns the value named {@code name} from {@code annotation}. * * @throws IllegalArgumentException unless that member represents a single type */ static TypeMirror getTypeValue(AnnotationMirror annotation, String name) { return MoreAnnotationValues.asType(getAnnotationValue(annotation, name)); }
@Override protected void process( TypeElement element, ImmutableSet<Class<? extends Annotation>> annotations) { monitoringModuleGenerator.generate(MoreElements.asType(element), messager); } }
/** Returns true if the type represents a producer-related framework type. */ static boolean isProducerType(TypeMirror type) { return isType(type) && typeIsOneOf(PRODUCTION_TYPES, type); }
/** * Wraps an {@link Optional} of a type in an {@code Optional} of a {@link Equivalence.Wrapper} for * that type. */ static Optional<Equivalence.Wrapper<AnnotationMirror>> wrapOptionalInEquivalence( Optional<AnnotationMirror> optional) { return optional.map(AnnotationMirrors.equivalence()::wrap); }
static ImmutableSet<? extends AnnotationMirror> getQualifiers(Element element) { return AnnotationMirrors.getAnnotatedAnnotations(element, Qualifier.class); }
/** * The contribution type from a binding method annotations. Presumes a well-formed binding method * (at most one of @IntoSet, @IntoMap, @ElementsIntoSet and @Provides.type). {@link * ProvidesMethodValidator} and {@link ProducesMethodValidator} validate correctness on their own. */ static ContributionType fromBindingMethod(ExecutableElement method) { if (isAnnotationPresent(method, IntoMap.class)) { return ContributionType.MAP; } else if (isAnnotationPresent(method, IntoSet.class)) { return ContributionType.SET; } else if (isAnnotationPresent(method, ElementsIntoSet.class)) { return ContributionType.SET_VALUES; } return ContributionType.UNIQUE; } }
@Override public TypeName visitDeclared(DeclaredType t, Void p) { return ClassName.get(MoreTypes.asTypeElement(t)); }
/** Returns true if the type represents a framework type. */ static boolean isFrameworkType(TypeMirror type) { return isType(type) && (typeIsOneOf(PROVISION_TYPES, type) || typeIsOneOf(PRODUCTION_TYPES, type)); }