org.guiceyfruit.support.internal
Class Errors

java.lang.Object
  extended by org.guiceyfruit.support.internal.Errors
All Implemented Interfaces:
java.io.Serializable

public final class Errors
extends java.lang.Object
implements java.io.Serializable

A collection of error messages. If this type is passed as a method parameter, the method is considered to have executed succesfully only if new errors were not added to this collection.

Author:
jessewilson@google.com (Jesse Wilson)
See Also:
Serialized Form

Constructor Summary
Errors()
           
Errors(java.lang.Object source)
           
 
Method Summary
 Errors addMessage(com.google.inject.spi.Message message)
           
 Errors addMessage(java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... arguments)
           
 Errors ambiguousTypeConversion(java.lang.String stringValue, java.lang.Object source, com.google.inject.TypeLiteral<?> type, com.google.inject.internal.MatcherAndConverter a, com.google.inject.internal.MatcherAndConverter b)
           
 Errors bindingAlreadySet(com.google.inject.Key<?> key, java.lang.Object source)
           
 Errors bindingToProvider()
           
 Errors cannotBindToGuiceType(java.lang.String simpleName)
           
 Errors cannotInjectInnerClass(java.lang.Class<?> type)
           
 Errors cannotInjectRawProvider()
           
 Errors cannotSatisfyCircularDependency(java.lang.Class<?> expectedType)
           
<T> T
checkForNull(T value, java.lang.Object source, com.google.inject.spi.Dependency<?> dependency)
          Returns value if it is non-null allowed to be null.
 Errors childBindingAlreadySet(com.google.inject.Key<?> key)
           
 Errors conversionError(java.lang.String stringValue, java.lang.Object source, com.google.inject.TypeLiteral<?> type, com.google.inject.internal.MatcherAndConverter matchingConverter, java.lang.Exception cause)
           
 Errors conversionTypeError(java.lang.String stringValue, java.lang.Object source, com.google.inject.TypeLiteral<?> type, com.google.inject.internal.MatcherAndConverter matchingConverter, java.lang.Object converted)
           
static java.lang.Object convert(java.lang.Object o)
           
 Errors converterReturnedNull(java.lang.String stringValue, java.lang.Object source, com.google.inject.TypeLiteral<?> type, com.google.inject.internal.MatcherAndConverter matchingConverter)
           
 Errors duplicateBindingAnnotations(java.lang.reflect.Member member, java.lang.Class<? extends java.lang.annotation.Annotation> a, java.lang.Class<? extends java.lang.annotation.Annotation> b)
           
 Errors duplicateScopeAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation> a, java.lang.Class<? extends java.lang.annotation.Annotation> b)
           
 Errors duplicateScopes(com.google.inject.Scope existing, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, com.google.inject.Scope scope)
           
 Errors errorInjectingConstructor(java.lang.Throwable cause)
           
 Errors errorInjectingMethod(java.lang.Throwable cause)
           
 Errors errorInProvider(java.lang.RuntimeException runtimeException, Errors errorsFromException)
           
static java.lang.String format(java.lang.String heading, java.util.Collection<? extends com.google.inject.spi.Message> errorMessages)
           
 java.util.List<com.google.inject.spi.Message> getMessages()
           
 boolean hasErrors()
           
 Errors makeImmutable()
           
 Errors merge(java.util.Collection<com.google.inject.spi.Message> messages)
           
 Errors merge(Errors moreErrors)
           
 Errors misplacedBindingAnnotation(java.lang.reflect.Member member, java.lang.annotation.Annotation bindingAnnotation)
           
 Errors missingConstantValues()
           
 Errors missingConstructor(java.lang.Class<?> implementation)
           
 Errors missingImplementation(java.lang.Object keyOrType)
          We use a fairly generic error message here.
 Errors missingRuntimeRetention(java.lang.Object source)
           
 Errors missingScopeAnnotation()
           
 Errors notASubtype(java.lang.Class<?> implementationType, java.lang.Class<?> type)
           
 Errors optionalConstructor(java.lang.reflect.Constructor constructor)
           
 void popSource(java.lang.Object source)
           
 void pushSource(java.lang.Object source)
           
 Errors recursiveBinding()
           
 Errors recursiveImplementationType()
           
 Errors recursiveProviderType()
           
 Errors scopeAnnotationOnAbstractType(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation, java.lang.Class<?> type, java.lang.Object source)
           
 Errors scopeNotFound(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation)
           
static java.lang.String sourceToString(java.lang.Object source)
          This method returns a String that indicates an element source.
 Errors subtypeNotProvided(java.lang.Class<? extends com.google.inject.Provider<?>> providerType, java.lang.Class<?> type)
           
 void throwCreationExceptionIfErrorsExist()
           
 void throwIfNecessary()
           
 ErrorsException toException()
           
 Errors tooManyConstructors(java.lang.Class<?> implementation)
           
 Errors withSource(java.lang.Object source)
          Returns an instance that uses source as a reference point for newly added errors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Errors

public Errors()

Errors

public Errors(java.lang.Object source)
Method Detail

withSource

public Errors withSource(java.lang.Object source)
Returns an instance that uses source as a reference point for newly added errors.


pushSource

public void pushSource(java.lang.Object source)

popSource

public void popSource(java.lang.Object source)

missingImplementation

public Errors missingImplementation(java.lang.Object keyOrType)
We use a fairly generic error message here. The motivation is to share the same message for both bind time errors:
Guice.createInjector(new AbstractModule() {
   public void configure() {
     bind(Runnable.class);
   }
 }
...and at provide-time errors:
Guice.createInjector().getInstance(Runnable.class);
Otherwise we need to know who's calling when resolving a just-in-time binding, which makes things unnecessarily complex.


converterReturnedNull

public Errors converterReturnedNull(java.lang.String stringValue,
                                    java.lang.Object source,
                                    com.google.inject.TypeLiteral<?> type,
                                    com.google.inject.internal.MatcherAndConverter matchingConverter)

conversionTypeError

public Errors conversionTypeError(java.lang.String stringValue,
                                  java.lang.Object source,
                                  com.google.inject.TypeLiteral<?> type,
                                  com.google.inject.internal.MatcherAndConverter matchingConverter,
                                  java.lang.Object converted)

conversionError

public Errors conversionError(java.lang.String stringValue,
                              java.lang.Object source,
                              com.google.inject.TypeLiteral<?> type,
                              com.google.inject.internal.MatcherAndConverter matchingConverter,
                              java.lang.Exception cause)

ambiguousTypeConversion

public Errors ambiguousTypeConversion(java.lang.String stringValue,
                                      java.lang.Object source,
                                      com.google.inject.TypeLiteral<?> type,
                                      com.google.inject.internal.MatcherAndConverter a,
                                      com.google.inject.internal.MatcherAndConverter b)

bindingToProvider

public Errors bindingToProvider()

subtypeNotProvided

public Errors subtypeNotProvided(java.lang.Class<? extends com.google.inject.Provider<?>> providerType,
                                 java.lang.Class<?> type)

notASubtype

public Errors notASubtype(java.lang.Class<?> implementationType,
                          java.lang.Class<?> type)

recursiveImplementationType

public Errors recursiveImplementationType()

recursiveProviderType

public Errors recursiveProviderType()

missingRuntimeRetention

public Errors missingRuntimeRetention(java.lang.Object source)

missingScopeAnnotation

public Errors missingScopeAnnotation()

optionalConstructor

public Errors optionalConstructor(java.lang.reflect.Constructor constructor)

cannotBindToGuiceType

public Errors cannotBindToGuiceType(java.lang.String simpleName)

scopeNotFound

public Errors scopeNotFound(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation)

scopeAnnotationOnAbstractType

public Errors scopeAnnotationOnAbstractType(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation,
                                            java.lang.Class<?> type,
                                            java.lang.Object source)

misplacedBindingAnnotation

public Errors misplacedBindingAnnotation(java.lang.reflect.Member member,
                                         java.lang.annotation.Annotation bindingAnnotation)

missingConstructor

public Errors missingConstructor(java.lang.Class<?> implementation)

tooManyConstructors

public Errors tooManyConstructors(java.lang.Class<?> implementation)

duplicateScopes

public Errors duplicateScopes(com.google.inject.Scope existing,
                              java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
                              com.google.inject.Scope scope)

missingConstantValues

public Errors missingConstantValues()

cannotInjectInnerClass

public Errors cannotInjectInnerClass(java.lang.Class<?> type)

duplicateBindingAnnotations

public Errors duplicateBindingAnnotations(java.lang.reflect.Member member,
                                          java.lang.Class<? extends java.lang.annotation.Annotation> a,
                                          java.lang.Class<? extends java.lang.annotation.Annotation> b)

duplicateScopeAnnotations

public Errors duplicateScopeAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation> a,
                                        java.lang.Class<? extends java.lang.annotation.Annotation> b)

recursiveBinding

public Errors recursiveBinding()

bindingAlreadySet

public Errors bindingAlreadySet(com.google.inject.Key<?> key,
                                java.lang.Object source)

childBindingAlreadySet

public Errors childBindingAlreadySet(com.google.inject.Key<?> key)

errorInjectingMethod

public Errors errorInjectingMethod(java.lang.Throwable cause)

errorInjectingConstructor

public Errors errorInjectingConstructor(java.lang.Throwable cause)

errorInProvider

public Errors errorInProvider(java.lang.RuntimeException runtimeException,
                              Errors errorsFromException)

cannotInjectRawProvider

public Errors cannotInjectRawProvider()

cannotSatisfyCircularDependency

public Errors cannotSatisfyCircularDependency(java.lang.Class<?> expectedType)

makeImmutable

public Errors makeImmutable()

throwCreationExceptionIfErrorsExist

public void throwCreationExceptionIfErrorsExist()

merge

public Errors merge(java.util.Collection<com.google.inject.spi.Message> messages)

merge

public Errors merge(Errors moreErrors)

throwIfNecessary

public void throwIfNecessary()
                      throws ErrorsException
Throws:
ErrorsException

toException

public ErrorsException toException()

hasErrors

public boolean hasErrors()

addMessage

public Errors addMessage(java.lang.Throwable cause,
                         java.lang.String messageFormat,
                         java.lang.Object... arguments)

addMessage

public Errors addMessage(com.google.inject.spi.Message message)

getMessages

public java.util.List<com.google.inject.spi.Message> getMessages()

format

public static java.lang.String format(java.lang.String heading,
                                      java.util.Collection<? extends com.google.inject.spi.Message> errorMessages)

checkForNull

public <T> T checkForNull(T value,
                          java.lang.Object source,
                          com.google.inject.spi.Dependency<?> dependency)
               throws ErrorsException
Returns value if it is non-null allowed to be null. Otherwise a message is added and an ErrorsException is thrown.

Throws:
ErrorsException

convert

public static java.lang.Object convert(java.lang.Object o)

sourceToString

public static java.lang.String sourceToString(java.lang.Object source)
This method returns a String that indicates an element source. We do a best effort to include a line number in this String.



Copyright © 2011. All Rights Reserved.