Package com.google.inject.internal
Class Errors
- java.lang.Object
-
- com.google.inject.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 successfully only if new errors were not added to this collection.Errors can be chained to provide additional context. To add context, call
withSource(java.lang.Object)
to create a new Errors instance that contains additional context. All messages added to the returned instance will contain full context.To avoid messages with redundant context,
withSource(java.lang.Object)
should be added sparingly. A good rule of thumb is to assume a method's caller has already specified enough context to identify that method. When calling a method that's defined in a different context, call that method with an errors object that includes its context.- Author:
- jessewilson@google.com (Jesse Wilson)
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Errors
addMessage(ErrorId errorId, java.lang.String messageFormat, java.lang.Object... arguments)
Errors
addMessage(Message message)
Errors
addMessage(java.lang.String messageFormat, java.lang.Object... arguments)
Errors
ambiguousTypeConversion(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, TypeConverterBinding a, TypeConverterBinding b)
Errors
aopDisabled(InterceptorBinding binding)
Errors
atInjectRequired(TypeLiteral<?> type)
Errors
atTargetIsMissingParameter(java.lang.annotation.Annotation bindingAnnotation, java.lang.String parameterName, java.lang.Class<?> clazz)
Errors
bindingAlreadySet(Key<?> key, java.lang.Object source)
Errors
bindingToProvider()
Errors
cannotBindToGuiceType(java.lang.String simpleName)
Errors
cannotInjectAbstractMethod(java.lang.reflect.Method method)
Errors
cannotInjectFinalField(java.lang.reflect.Field field)
Errors
cannotInjectInnerClass(java.lang.Class<?> type)
Errors
cannotInjectLocalClass(java.lang.Class<?> type)
Errors
cannotInjectMethodWithTypeParameters(java.lang.reflect.Method method)
Errors
cannotInjectRawMembersInjector()
Errors
cannotInjectRawProvider()
Errors
cannotInjectRawTypeLiteral()
Errors
cannotInjectTypeLiteralOf(java.lang.reflect.Type unsupportedType)
Errors
childBindingAlreadySet(Key<?> key, java.util.Set<java.lang.Object> sources)
Errors
constructorNotDefinedByType(java.lang.reflect.Constructor<?> constructor, TypeLiteral<?> type)
Errors
conversionError(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding, java.lang.RuntimeException cause)
Errors
conversionTypeError(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding, java.lang.Object converted)
static java.lang.Object
convert(java.lang.Object o)
static java.lang.Object
convert(java.lang.Object o, ElementSource source)
Errors
converterReturnedNull(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding)
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)
<K,V>
ErrorsduplicateMapKey(Key<java.util.Map<K,V>> mapKey, com.google.common.collect.Multimap<K,Binding<V>> duplicates)
Errors
duplicateScopeAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation> a, java.lang.Class<? extends java.lang.annotation.Annotation> b)
Errors
duplicateScopes(ScopeBinding existing, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, Scope scope)
Errors
errorCheckingDuplicateBinding(Key<?> key, java.lang.Object source, java.lang.Throwable t)
Errors
errorEnhancingClass(java.lang.Class<?> clazz, java.lang.Throwable cause)
Errors
errorInUserCode(java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... arguments)
Errors
errorNotifyingTypeListener(TypeListenerBinding listener, TypeLiteral<?> type, java.lang.Throwable cause)
Errors
exposedButNotBound(Key<?> key)
static java.lang.String
format(java.lang.String messageFormat, java.lang.Object... arguments)
static void
formatSource(java.util.Formatter formatter, java.lang.Object source)
java.util.List<Message>
getMessages()
static java.util.Collection<Message>
getMessagesFromThrowable(java.lang.Throwable throwable)
boolean
hasErrors()
Errors
jitBindingAlreadySet(Key<?> key)
Errors
jitDisabled(Key<?> key)
Errors
jitDisabledInParent(Key<?> key)
Errors
keyNotFullySpecified(TypeLiteral<?> typeLiteral)
Errors
merge(Errors moreErrors)
Errors
merge(InternalProvisionException ipe)
Errors
merge(java.util.Collection<Message> messages)
Errors
misplacedBindingAnnotation(java.lang.reflect.Member member, java.lang.annotation.Annotation bindingAnnotation)
Errors
missingConstantValues()
Errors
missingConstructor(TypeLiteral<?> type)
Errors
missingImplementation(Key<?> key)
We use a fairly generic error message here.Errors
missingRuntimeRetention(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Errors
missingScopeAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Errors
notASubtype(java.lang.Class<?> implementationType, java.lang.Class<?> type)
Errors
optionalConstructor(java.lang.reflect.Constructor<?> constructor)
Errors
recursiveBinding(Key<?> key, Key<?> linkedKey)
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)
int
size()
Errors
staticInjectionOnInterface(java.lang.Class<?> clazz)
void
throwConfigurationExceptionIfErrorsExist()
void
throwCreationExceptionIfErrorsExist()
void
throwIfNewErrors(int expectedSize)
void
throwProvisionExceptionIfErrorsExist()
ErrorsException
toException()
Errors
tooManyConstructors(java.lang.Class<?> implementation)
Errors
voidProviderMethod()
Errors
withSource(java.lang.Object source)
Returns an instance that usessource
as a reference point for newly added errors.
-
-
-
Method Detail
-
withSource
public Errors withSource(java.lang.Object source)
Returns an instance that usessource
as a reference point for newly added errors.
-
aopDisabled
public Errors aopDisabled(InterceptorBinding binding)
-
missingImplementation
public Errors missingImplementation(Key<?> key)
We use a fairly generic error message here. The motivation is to share the same message for both bind time errors:
...and at provide-time errors:Guice.createInjector(new AbstractModule() { public void configure() { bind(Runnable.class); } }
Otherwise we need to know who's calling when resolving a just-in-time binding, which makes things unnecessarily complex.Guice.createInjector().getInstance(Runnable.class);
-
atInjectRequired
public Errors atInjectRequired(TypeLiteral<?> type)
-
converterReturnedNull
public Errors converterReturnedNull(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding)
-
conversionTypeError
public Errors conversionTypeError(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding, java.lang.Object converted)
-
conversionError
public Errors conversionError(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding, java.lang.RuntimeException cause)
-
ambiguousTypeConversion
public Errors ambiguousTypeConversion(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, TypeConverterBinding a, TypeConverterBinding b)
-
bindingToProvider
public Errors bindingToProvider()
-
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.Class<? extends java.lang.annotation.Annotation> annotation)
-
missingScopeAnnotation
public Errors missingScopeAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
-
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(TypeLiteral<?> type)
-
tooManyConstructors
public Errors tooManyConstructors(java.lang.Class<?> implementation)
-
constructorNotDefinedByType
public Errors constructorNotDefinedByType(java.lang.reflect.Constructor<?> constructor, TypeLiteral<?> type)
-
duplicateMapKey
public <K,V> Errors duplicateMapKey(Key<java.util.Map<K,V>> mapKey, com.google.common.collect.Multimap<K,Binding<V>> duplicates)
-
duplicateScopes
public Errors duplicateScopes(ScopeBinding existing, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, Scope scope)
-
voidProviderMethod
public Errors voidProviderMethod()
-
missingConstantValues
public Errors missingConstantValues()
-
cannotInjectInnerClass
public Errors cannotInjectInnerClass(java.lang.Class<?> type)
-
cannotInjectLocalClass
public Errors cannotInjectLocalClass(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)
-
staticInjectionOnInterface
public Errors staticInjectionOnInterface(java.lang.Class<?> clazz)
-
cannotInjectFinalField
public Errors cannotInjectFinalField(java.lang.reflect.Field field)
-
atTargetIsMissingParameter
public Errors atTargetIsMissingParameter(java.lang.annotation.Annotation bindingAnnotation, java.lang.String parameterName, java.lang.Class<?> clazz)
-
cannotInjectAbstractMethod
public Errors cannotInjectAbstractMethod(java.lang.reflect.Method method)
-
cannotInjectMethodWithTypeParameters
public Errors cannotInjectMethodWithTypeParameters(java.lang.reflect.Method method)
-
duplicateScopeAnnotations
public Errors duplicateScopeAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation> a, java.lang.Class<? extends java.lang.annotation.Annotation> b)
-
childBindingAlreadySet
public Errors childBindingAlreadySet(Key<?> key, java.util.Set<java.lang.Object> sources)
-
errorCheckingDuplicateBinding
public Errors errorCheckingDuplicateBinding(Key<?> key, java.lang.Object source, java.lang.Throwable t)
-
errorNotifyingTypeListener
public Errors errorNotifyingTypeListener(TypeListenerBinding listener, TypeLiteral<?> type, java.lang.Throwable cause)
-
keyNotFullySpecified
public Errors keyNotFullySpecified(TypeLiteral<?> typeLiteral)
-
errorEnhancingClass
public Errors errorEnhancingClass(java.lang.Class<?> clazz, java.lang.Throwable cause)
-
getMessagesFromThrowable
public static java.util.Collection<Message> getMessagesFromThrowable(java.lang.Throwable throwable)
-
errorInUserCode
public Errors errorInUserCode(java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... arguments)
-
cannotInjectRawProvider
public Errors cannotInjectRawProvider()
-
cannotInjectRawMembersInjector
public Errors cannotInjectRawMembersInjector()
-
cannotInjectTypeLiteralOf
public Errors cannotInjectTypeLiteralOf(java.lang.reflect.Type unsupportedType)
-
cannotInjectRawTypeLiteral
public Errors cannotInjectRawTypeLiteral()
-
throwCreationExceptionIfErrorsExist
public void throwCreationExceptionIfErrorsExist()
-
throwConfigurationExceptionIfErrorsExist
public void throwConfigurationExceptionIfErrorsExist()
-
throwProvisionExceptionIfErrorsExist
public void throwProvisionExceptionIfErrorsExist()
-
merge
public Errors merge(InternalProvisionException ipe)
-
throwIfNewErrors
public void throwIfNewErrors(int expectedSize) throws ErrorsException
- Throws:
ErrorsException
-
toException
public ErrorsException toException()
-
hasErrors
public boolean hasErrors()
-
addMessage
public Errors addMessage(java.lang.String messageFormat, java.lang.Object... arguments)
-
addMessage
public Errors addMessage(ErrorId errorId, java.lang.String messageFormat, java.lang.Object... arguments)
-
format
public static java.lang.String format(java.lang.String messageFormat, java.lang.Object... arguments)
-
getMessages
public java.util.List<Message> getMessages()
-
size
public int size()
-
convert
public static java.lang.Object convert(java.lang.Object o)
-
convert
public static java.lang.Object convert(java.lang.Object o, ElementSource source)
-
formatSource
public static void formatSource(java.util.Formatter formatter, java.lang.Object source)
-
-