DependencyRequest forComponentMembersInjectionMethod( ExecutableElement membersInjectionMethod, ExecutableType membersInjectionMethodType) { checkNotNull(membersInjectionMethod); checkNotNull(membersInjectionMethodType); Optional<AnnotationMirror> qualifier = InjectionAnnotations.getQualifier(membersInjectionMethod); checkArgument(!qualifier.isPresent()); TypeMirror membersInjectedType = getOnlyElement(membersInjectionMethodType.getParameterTypes()); return DependencyRequest.builder() .kind(MEMBERS_INJECTION) .key(keyFactory.forMembersInjectedType(membersInjectedType)) .requestElement(membersInjectionMethod) .build(); }
/** Creates a synthetic dependency request for one individual {@code multibindingContribution}. */ private DependencyRequest forMultibindingContribution( Key multibindingKey, ContributionBinding multibindingContribution) { checkArgument( multibindingContribution.key().multibindingContributionIdentifier().isPresent(), "multibindingContribution's key must have a multibinding contribution identifier: %s", multibindingContribution); return DependencyRequest.builder() .kind(multibindingContributionRequestKind(multibindingKey, multibindingContribution)) .key(multibindingContribution.key()) .build(); }
/** * Returns a synthetic request for the present value of an optional binding generated from a * {@link dagger.BindsOptionalOf} declaration. */ DependencyRequest forSyntheticPresentOptionalBinding(Key requestKey, RequestKind kind) { Optional<Key> key = keyFactory.unwrapOptional(requestKey); checkArgument(key.isPresent(), "not a request for optional: %s", requestKey); return DependencyRequest.builder() .kind(kind) .key(key.get()) .isNullable( allowsNull(getRequestKind(OptionalType.from(requestKey).valueType()), Optional.empty())) .build(); }
DependencyRequest forProductionImplementationExecutor() { return DependencyRequest.builder() .kind(PROVIDER) .key(keyFactory.forProductionImplementationExecutor()) .build(); }
DependencyRequest forProductionComponentMonitor() { return DependencyRequest.builder() .kind(PROVIDER) .key(keyFactory.forProductionComponentMonitor()) .build(); }
DependencyRequest forComponentProductionMethod( ExecutableElement productionMethod, ExecutableType productionMethodType) { checkNotNull(productionMethod); checkNotNull(productionMethodType); checkArgument( productionMethod.getParameters().isEmpty(), "Component production methods must be empty: %s", productionMethod); TypeMirror type = productionMethodType.getReturnType(); Optional<AnnotationMirror> qualifier = InjectionAnnotations.getQualifier(productionMethod); // Only a component production method can be a request for a ListenableFuture, so we // special-case it here. if (isTypeOf(ListenableFuture.class, type)) { return DependencyRequest.builder() .kind(FUTURE) .key(keyFactory.forQualifiedType(qualifier, types.unwrapType(type))) .requestElement(productionMethod) .build(); } else { return newDependencyRequest(productionMethod, type, qualifier); } }
private DependencyRequest newDependencyRequest( Element requestElement, TypeMirror type, Optional<AnnotationMirror> qualifier) { RequestKind requestKind = getRequestKind(type); return DependencyRequest.builder() .kind(requestKind) .key(keyFactory.forQualifiedType(qualifier, extractKeyType(requestKind, type))) .requestElement(requestElement) .isNullable(allowsNull(requestKind, getNullableType(requestElement))) .build(); }