private static ImmutableList<? extends Equivalence.Wrapper<? extends TypeMirror>> wrapInEquivalence(List<? extends TypeMirror> types) { return types.stream().map(MoreTypes.equivalence()::wrap).collect(toImmutableList()); } }
/** * Returns {@code true} iff the given element has an {@link AnnotationMirror} whose {@linkplain * AnnotationMirror#getAnnotationType() annotation type} is equivalent to {@code annotationType}. */ static boolean isAnnotationPresent(Element element, TypeMirror annotationType) { return element .getAnnotationMirrors() .stream() .map(AnnotationMirror::getAnnotationType) .anyMatch(candidate -> MoreTypes.equivalence().equivalent(candidate, annotationType)); }
@Override public Void visitType(TypeMirror includedModule, AnnotationValue value) { if (MoreTypes.equivalence().equivalent(module.asType(), includedModule)) { Name moduleKind = moduleAnnotation.getAnnotationType().asElement().getSimpleName(); builder.addError( String.format("@%s cannot include themselves.", moduleKind), module, moduleAnnotation, value); } return null; }
static ComponentRequirement forBoundInstance(Key key, boolean nullable, String variableName) { return new AutoValue_ComponentRequirement( Kind.BOUND_INSTANCE, MoreTypes.equivalence().wrap(key.type()), nullable ? Optional.of(NullPolicy.ALLOW) : Optional.empty(), Optional.of(key), variableName); }
private static ImmutableSetMultimap<Equivalence.Wrapper<DeclaredType>, ContributionBinding> indexByMapKeyAnnotationType(ImmutableSet<ContributionBinding> contributions) { return ImmutableSetMultimap.copyOf( Multimaps.index( contributions, mapBinding -> MoreTypes.equivalence() .wrap(mapBinding.mapKeyAnnotation().get().getAnnotationType()))); }
static ComponentRequirement forDependency(TypeMirror type) { return new AutoValue_ComponentRequirement( Kind.DEPENDENCY, MoreTypes.equivalence().wrap(checkNotNull(type)), Optional.empty(), Optional.empty(), simpleVariableName(MoreTypes.asTypeElement(type))); }
private static ModifiableBindingMethod create( ModifiableBindingType type, BindingRequest request, TypeMirror returnType, MethodSpec methodSpec, boolean finalized) { return new AutoValue_ModifiableBindingMethods_ModifiableBindingMethod( type, request, MoreTypes.equivalence().wrap(returnType), methodSpec, finalized); }
static ComponentRequirement forModule(TypeMirror type) { return new AutoValue_ComponentRequirement( Kind.MODULE, MoreTypes.equivalence().wrap(checkNotNull(type)), Optional.empty(), Optional.empty(), simpleVariableName(MoreTypes.asTypeElement(type))); }
/** * Returns a {@link SetType} for {@code type}. * * @throws IllegalArgumentException if {@code type} is not a {@link Set} type */ static SetType from(TypeMirror type) { checkArgument(isSet(type), "%s must be a Set", type); return new AutoValue_SetType(MoreTypes.equivalence().wrap(MoreTypes.asDeclared(type))); }
/** * Returns a {@link OptionalType} for {@code type}. * * @throws IllegalArgumentException if {@code type} is not an {@code Optional} type */ static OptionalType from(TypeMirror type) { checkArgument(isOptional(type), "%s must be an Optional", type); return new AutoValue_OptionalType(MoreTypes.equivalence().wrap(MoreTypes.asDeclared(type))); }
/** * Returns a {@link MapType} for {@code type}. * * @throws IllegalArgumentException if {@code type} is not a {@link Map} type */ static MapType from(TypeMirror type) { checkArgument(isMap(type), "%s is not a Map", type); return new AutoValue_MapType(MoreTypes.equivalence().wrap(MoreTypes.asDeclared(type))); }
private String formatSubcomponentDeclaration(SubcomponentDeclaration subcomponentDeclaration) { ImmutableList<TypeMirror> moduleSubcomponents = getModuleSubcomponents(subcomponentDeclaration.moduleAnnotation()); int index = Iterables.indexOf( moduleSubcomponents, MoreTypes.equivalence() .equivalentTo(subcomponentDeclaration.subcomponentType().asType())); StringBuilder annotationValue = new StringBuilder(); if (moduleSubcomponents.size() != 1) { annotationValue.append("{"); } annotationValue.append( formatArgumentInList( index, moduleSubcomponents.size(), subcomponentDeclaration.subcomponentType().getQualifiedName() + ".class")); if (moduleSubcomponents.size() != 1) { annotationValue.append("}"); } return String.format( "@%s(subcomponents = %s) for %s", simpleName(subcomponentDeclaration.moduleAnnotation()), annotationValue, subcomponentDeclaration.contributingModule().get()); } }
&& MoreTypes.equivalence() .equivalent(contributesAndroidInjector, annotation.getAnnotationType())) { builder.addSubreport(
if (parameterTypes.size() == 1 && (returnType.getKind().equals(VOID) || MoreTypes.equivalence().equivalent(returnType, parameterTypes.get(0)))) { return ComponentMethodDescriptor.forMembersInjection( componentMethod,