public Errors misplacedBindingAnnotation(Member member, Annotation bindingAnnotation) { return addMessage( "%s is annotated with %s, but binding annotations should be applied " + "to its parameters instead.", member, bindingAnnotation); }
public Errors atInjectRequired(Class clazz) { return addMessage( "Explicit @Inject annotations are required on constructors," + " but %s has no constructors annotated with @Inject.", clazz); }
public Errors optionalConstructor(Constructor constructor) { return addMessage( "%s is annotated @Inject(optional=true), but constructors cannot be optional.", constructor); }
public Errors tooManyConstructors(Class<?> implementation) { return addMessage( "%s has more than one constructor annotated with @Inject. " + CONSTRUCTOR_RULES, implementation); }
public Errors cannotInjectInnerClass(Class<?> type) { return addMessage( "Injecting into inner classes is not supported. " + "Please use a 'static' class (top-level or nested) instead of %s.", type); }
public Errors jitDisabledInParent(Key<?> key) { return addMessage( "Explicit bindings are required and %s would be bound in a parent injector.%n" + "Please add an explicit binding for it, either in the child or the parent.", key); }
public Errors duplicateBindingAnnotations( Member member, Class<? extends Annotation> a, Class<? extends Annotation> b) { return addMessage( "%s has more than one annotation annotated with @BindingAnnotation: %s and %s", member, a, b); }
public Errors missingConstructor(Class<?> implementation) { return addMessage( "Could not find a suitable constructor in %s. " + CONSTRUCTOR_RULES, implementation); }
public Errors duplicateScopeAnnotations( Class<? extends Annotation> a, Class<? extends Annotation> b) { return addMessage("More than one scope annotation was found: %s and %s.", a, b); }
public Errors jitBindingAlreadySet(Key<?> key) { return addMessage( "A just-in-time binding to %s was already configured on a parent injector.", key); }
@Override public void addError(String message, Object... arguments) { checkState(valid, "Encounters may not be used after hear() returns."); errors.addMessage(message, arguments); }
@Override public void addError(Message message) { checkState(valid, "Encounters may not be used after hear() returns."); errors.addMessage(message); }
public Errors errorCheckingDuplicateBinding(Key<?> key, Object source, Throwable t) { return addMessage( "A binding to %s was already configured at %s and an error was thrown " + "while checking duplicate bindings. Error: %s", key, convert(source), t); }
public Errors conversionTypeError( String stringValue, Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding, Object converted) { return addMessage( "Type mismatch converting '%s' (bound at %s) to %s%n" + " using %s.%n" + " Converter returned %s.", stringValue, convert(source), type, typeConverterBinding, converted); }
public Errors scopeAnnotationOnAbstractType( Class<? extends Annotation> scopeAnnotation, Class<?> type, Object source) { return addMessage( "%s is annotated with %s, but scope annotations are not supported " + "for abstract types.%n Bound at %s.", type, scopeAnnotation, convert(source)); }
public Errors converterReturnedNull( String stringValue, Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding) { return addMessage( "Received null converting '%s' (bound at %s) to %s%n using %s.", stringValue, convert(source), type, typeConverterBinding); }
public Errors errorInUserCode(Throwable cause, String messageFormat, Object... arguments) { Collection<Message> messages = getMessagesFromThrowable(cause); if (!messages.isEmpty()) { return merge(messages); } else { return addMessage(cause, messageFormat, arguments); } }
public Errors duplicateScopes( ScopeBinding existing, Class<? extends Annotation> annotationType, Scope scope) { return addMessage( "Scope %s is already bound to %s at %s.%n Cannot bind %s.", existing.getScope(), annotationType, existing.getSource(), scope); }
public Errors merge(Collection<Message> messages) { List<Object> sources = getSources(); for (Message message : messages) { addMessage(Messages.mergeSources(sources, message)); } return this; }
@Override public Boolean visit(Message message) { if (message.getCause() != null) { String rootMessage = getRootMessage(message.getCause()); logger.log( Level.INFO, "An exception was caught and reported. Message: " + rootMessage, message.getCause()); } errors.addMessage(message); return true; }