/** * Returns {@code true} if a given request element allows null values. {@link * RequestKind#INSTANCE} requests must be annotated with {@code @Nullable} in order to allow null * values. All other request kinds implicitly allow null values because they are are wrapped * inside {@link Provider}, {@link Lazy}, etc. */ private boolean allowsNull(RequestKind kind, Optional<DeclaredType> nullableType) { return nullableType.isPresent() || !kind.equals(INSTANCE); } }
@Override public String toString() { String string = dependencyRequest .requestElement() .map(DaggerElements::elementToString) .orElseGet( () -> "synthetic request for " + dependencyRequest.kind().format(dependencyRequest.key())); return entryPoint ? string + " (entry point)" : string; } }
@Override public int hashCode() { int h = 1; h *= 1000003; h ^= this.frameworkType.hashCode(); h *= 1000003; h ^= this.optionalKind.hashCode(); h *= 1000003; h ^= this.valueKind.hashCode(); return h; }
@Override public FrameworkType getFrameworkType(RequestKind requestKind) { switch (requestKind) { case INSTANCE: case PROVIDER: case PROVIDER_OF_LAZY: case LAZY: return FrameworkType.PROVIDER; case PRODUCED: case PRODUCER: throw new IllegalArgumentException(requestKind.toString()); default: throw new AssertionError(requestKind); } } },
/** The name of the factory class. */ String factoryClassName() { return new StringBuilder("Present") .append(UPPER_UNDERSCORE.to(UPPER_CAMEL, optionalKind().name())) .append(UPPER_UNDERSCORE.to(UPPER_CAMEL, valueKind().toString())) .append(frameworkType().frameworkClass().getSimpleName()) .toString(); }
/** Returns whether this request is of the given kind. */ final boolean isRequestKind(RequestKind requestKind) { return requestKind.equals(requestKind().orElse(null)); }
private ContributionBinding.Builder<?, ?> syntheticOptionalBindingBuilder( RequestKind requestKind, ResolvedBindings underlyingKeyBindings) { return !underlyingKeyBindings.isEmpty() && (underlyingKeyBindings.bindingTypes().contains(BindingType.PRODUCTION) || requestKind.equals(RequestKind.PRODUCER) // handles producerFromProvider cases || requestKind.equals(RequestKind.PRODUCED)) // handles producerFromProvider cases ? ProductionBinding.builder() : ProvisionBinding.builder(); }
/** Returns the {@link RequestKind} that matches the wrapping types (if any) of {@code type}. */ static RequestKind getRequestKind(TypeMirror type) { checkTypePresent(type); for (RequestKind kind : FRAMEWORK_CLASSES.keySet()) { if (matchesKind(kind, type)) { if (kind.equals(PROVIDER) && matchesKind(LAZY, extractKeyType(kind, type))) { return PROVIDER_OF_LAZY; } return kind; } } return INSTANCE; }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof OptionalFactories.PresentFactorySpec) { OptionalFactories.PresentFactorySpec that = (OptionalFactories.PresentFactorySpec) o; return (this.frameworkType.equals(that.frameworkType())) && (this.optionalKind.equals(that.optionalKind())) && (this.valueKind.equals(that.valueKind())); } return false; }
futureType, dependencyFutureName(dependency), dependency.kind().equals(RequestKind.PRODUCED) ? CodeBlock.of("$T.createFutureProduced($L)", PRODUCERS, futureAccess) : futureAccess);
private static CodeBlock injectionMethodArgument( DependencyRequest dependency, CodeBlock argument, ClassName generatedTypeName) { TypeMirror keyType = dependency.key().type(); CodeBlock.Builder codeBlock = CodeBlock.builder(); if (!isRawTypeAccessible(keyType, generatedTypeName.packageName()) && isTypeAccessibleFrom(keyType, generatedTypeName.packageName())) { if (!dependency.kind().equals(RequestKind.INSTANCE)) { TypeName usageTypeName = accessibleType(dependency); codeBlock.add("($T) ($T)", usageTypeName, rawTypeName(usageTypeName)); } else if (dependency.requestElement().get().asType().getKind().equals(TypeKind.TYPEVAR)) { codeBlock.add("($T)", keyType); } } return codeBlock.add(argument).build(); }
.forEach( entryPoint -> { if (entryPoint.kind().equals(MEMBERS_INJECTION)) { requestResolver.resolveMembersInjection(entryPoint.key()); } else {
if (dependencyRequest.kind().equals(RequestKind.INSTANCE) && !isTypeAccessibleFrom(dependencyType, requestingClass.packageName()) && isRawTypeAccessible(dependencyType, requestingClass.packageName())) {