/** Returns the scope annotation on {@code type}, or null if none is specified. */ public static Class<? extends Annotation> findScopeAnnotation( Errors errors, Class<?> implementation) { return findScopeAnnotation(errors, implementation.getAnnotations()); }
/** * Adds an error if there is a misplaced annotations on {@code type}. Scoping annotations are not * allowed on abstract classes or interfaces. */ public static void checkForMisplacedScopeAnnotations( Class<?> type, Object source, Errors errors) { if (Classes.isConcrete(type)) { return; } Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type); if (scopeAnnotation != null // We let Dagger Components through to aid migrations. && !containsComponentAnnotation(type.getAnnotations())) { errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source); } }
private <T> ProviderMethod<T> createProviderMethod( Binder binder, Method method, Annotation annotation) { binder = binder.withSource(method); Errors errors = new Errors(method); // prepare the parameter providers InjectionPoint point = InjectionPoint.forMethod(method, typeLiteral); @SuppressWarnings("unchecked") // Define T as the method's return type. TypeLiteral<T> returnType = (TypeLiteral<T>) typeLiteral.getReturnType(method); Key<T> key = getKey(errors, returnType, method, method.getAnnotations()); try { key = scanner.prepareMethod(binder, annotation, key, point); } catch (Throwable t) { binder.addError(t); } Class<? extends Annotation> scopeAnnotation = Annotations.findScopeAnnotation(errors, method.getAnnotations()); for (Message message : errors.getMessages()) { binder.addError(message); } return ProviderMethod.create( key, method, delegate, ImmutableSet.copyOf(point.getDependencies()), scopeAnnotation, skipFastClassGeneration, annotation); }
Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, annotatedType); if (scopeAnnotation != null) { scoping =
/** Returns the scope annotation on {@code type}, or null if none is specified. */ public static Class<? extends Annotation> findScopeAnnotation( Errors errors, Class<?> implementation) { return findScopeAnnotation(errors, implementation.getAnnotations()); }
/** Returns the scope annotation on {@code type}, or null if none is specified. */ public static Class<? extends Annotation> findScopeAnnotation( Errors errors, Class<?> implementation) { return findScopeAnnotation(errors, implementation.getAnnotations()); }
/** Returns the scope annotation on {@code type}, or null if none is specified. */ public static Class<? extends Annotation> findScopeAnnotation( Errors errors, Class<?> implementation) { return findScopeAnnotation(errors, implementation.getAnnotations()); }
/** Returns the scope annotation on {@code type}, or null if none is specified. */ public static Class<? extends Annotation> findScopeAnnotation( Errors errors, Class<?> implementation) { return findScopeAnnotation(errors, implementation.getAnnotations()); }
/** Returns the scope annotation on {@code type}, or null if none is specified. */ public static Class<? extends Annotation> findScopeAnnotation( Errors errors, Class<?> implementation) { return findScopeAnnotation(errors, implementation.getAnnotations()); }
/** * Returns the scope annotation on {@code type}, or null if none is specified. */ public static Class<? extends Annotation> findScopeAnnotation( Errors errors, Class<?> implementation) { return findScopeAnnotation(errors, implementation.getAnnotations()); }
private void verifyAbsenseOfScopeAnnotation(Errors methodErrors, Annotation[] annotations, Object source) { @Nullable Class<? extends Annotation> methodScopeAnnotation = Annotations.findScopeAnnotation(methodErrors, annotations); if (methodScopeAnnotation != null) { methodErrors.addMessage( "Misplaced scope annotation @%s on method @%s %s.%n Scope annotation will be inherited from enclosing class %s", methodScopeAnnotation.getSimpleName(), EventuallyProvides.class.getSimpleName(), source, providersClass.getSimpleName()); } }
EventualProvider( Invokable<T, ?> method, boolean exposedBinding, List<Dependency<ListenableFuture<?>>> dependencies, Key<ListenableFuture<?>> bindingKey, @Nullable Class<? extends Annotation> scopeAnnotation, Object source) { this.method = method; this.source = source; this.exposedBinding = exposedBinding; this.bindingKey = bindingKey; this.scopeAnnotation = scopeAnnotation; this.dependencies = ImmutableList.copyOf(dependencies); this.dependencySet = ImmutableSet.<Dependency<?>>builder() .addAll(dependencies) .add(Dependency.get(Key.get(Injector.class))) .add(Dependency.get(Key.get(type.getRawType()))) .build(); }
/** * Adds an error if there is a misplaced annotations on {@code type}. Scoping * annotations are not allowed on abstract classes or interfaces. */ public static void checkForMisplacedScopeAnnotations( Class<?> type, Object source, Errors errors) { if (Classes.isConcrete(type)) { return; } Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type); if (scopeAnnotation != null) { errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source); } }
/** * Adds an error if there is a misplaced annotations on {@code type}. Scoping * annotations are not allowed on abstract classes or interfaces. */ public static void checkForMisplacedScopeAnnotations( Class<?> type, Object source, Errors errors) { if (Classes.isConcrete(type)) { return; } Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type); if (scopeAnnotation != null) { errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source); } }
/** * Adds an error if there is a misplaced annotations on {@code type}. Scoping * annotations are not allowed on abstract classes or interfaces. */ public static void checkForMisplacedScopeAnnotations( Class<?> type, Object source, Errors errors) { if (Classes.isConcrete(type)) { return; } Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type); if (scopeAnnotation != null) { errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source); } }
/** * Adds an error if there is a misplaced annotations on {@code type}. Scoping annotations are not * allowed on abstract classes or interfaces. */ public static void checkForMisplacedScopeAnnotations( Class<?> type, Object source, Errors errors) { if (Classes.isConcrete(type)) { return; } Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type); if (scopeAnnotation != null // We let Dagger Components through to aid migrations. && !containsComponentAnnotation(type.getAnnotations())) { errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source); } }
/** * Adds an error if there is a misplaced annotations on {@code type}. Scoping annotations are not * allowed on abstract classes or interfaces. */ public static void checkForMisplacedScopeAnnotations( Class<?> type, Object source, Errors errors) { if (Classes.isConcrete(type)) { return; } Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type); if (scopeAnnotation != null // We let Dagger Components through to aid migrations. && !containsComponentAnnotation(type.getAnnotations())) { errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source); } }
/** * Adds an error if there is a misplaced annotations on {@code type}. Scoping * annotations are not allowed on abstract classes or interfaces. */ public static void checkForMisplacedScopeAnnotations( Class<?> type, Object source, Errors errors) { if (Classes.isConcrete(type)) { return; } Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type); if (scopeAnnotation != null // We let Dagger Components through to aid migrations. && !containsComponentAnnotation(type.getAnnotations())) { errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source); } }
private <T> ProviderMethod<T> createProviderMethod( Binder binder, Method method, Annotation annotation) { binder = binder.withSource(method); Errors errors = new Errors(method); // prepare the parameter providers InjectionPoint point = InjectionPoint.forMethod(method, typeLiteral); @SuppressWarnings("unchecked") // Define T as the method's return type. TypeLiteral<T> returnType = (TypeLiteral<T>) typeLiteral.getReturnType(method); Key<T> key = getKey(errors, returnType, method, method.getAnnotations()); try { key = scanner.prepareMethod(binder, annotation, key, point); } catch (Throwable t) { binder.addError(t); } Class<? extends Annotation> scopeAnnotation = Annotations.findScopeAnnotation(errors, method.getAnnotations()); for (Message message : errors.getMessages()) { binder.addError(message); } return ProviderMethod.create( key, method, delegate, ImmutableSet.copyOf(point.getDependencies()), scopeAnnotation, skipFastClassGeneration, annotation); }
private <T> ProviderMethod<T> createProviderMethod( Binder binder, Method method, Annotation annotation) { binder = binder.withSource(method); Errors errors = new Errors(method); // prepare the parameter providers InjectionPoint point = InjectionPoint.forMethod(method, typeLiteral); @SuppressWarnings("unchecked") // Define T as the method's return type. TypeLiteral<T> returnType = (TypeLiteral<T>) typeLiteral.getReturnType(method); Key<T> key = getKey(errors, returnType, method, method.getAnnotations()); try { key = scanner.prepareMethod(binder, annotation, key, point); } catch (Throwable t) { binder.addError(t); } Class<? extends Annotation> scopeAnnotation = Annotations.findScopeAnnotation(errors, method.getAnnotations()); for (Message message : errors.getMessages()) { binder.addError(message); } return ProviderMethod.create( key, method, delegate, ImmutableSet.copyOf(point.getDependencies()), scopeAnnotation, skipFastClassGeneration, annotation); }