Class Errors
- java.lang.Object
-
- org.elasticsearch.common.inject.internal.Errors
-
public final class Errors extends java.lang.Object
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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Errors
addMessage(java.lang.String messageFormat, java.lang.Object... arguments)
Errors
addMessage(Message message)
Errors
ambiguousTypeConversion(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter a, MatcherAndConverter b)
Errors
bindingAlreadySet(Key<?> key, java.lang.Object source)
Errors
bindingToProvider()
Errors
cannotBindToGuiceType(java.lang.String simpleName)
Errors
cannotInjectInnerClass(java.lang.Class<?> type)
Errors
cannotInjectRawMembersInjector()
Errors
cannotInjectRawProvider()
Errors
cannotInjectRawTypeLiteral()
Errors
cannotInjectTypeLiteralOf(java.lang.reflect.Type unsupportedType)
Errors
cannotSatisfyCircularDependency(java.lang.Class<?> expectedType)
<T> T
checkForNull(T value, java.lang.Object source, Dependency<?> dependency)
Returnsvalue
if it is non-null allowed to be null.Errors
childBindingAlreadySet(Key<?> key)
Errors
conversionError(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter, java.lang.RuntimeException cause)
Errors
conversionTypeError(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, 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, TypeLiteral<?> type, 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(Scope existing, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, Scope scope)
Errors
errorInjectingConstructor(java.lang.Throwable cause)
Errors
errorInjectingMethod(java.lang.Throwable cause)
Errors
errorInProvider(java.lang.RuntimeException runtimeException)
Errors
errorInUserCode(java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... arguments)
Errors
errorInUserInjector(MembersInjector<?> listener, TypeLiteral<?> type, java.lang.RuntimeException cause)
Errors
errorNotifyingInjectionListener(InjectionListener<?> listener, TypeLiteral<?> type, java.lang.RuntimeException cause)
Errors
errorNotifyingTypeListener(TypeListenerBinding listener, TypeLiteral<?> type, java.lang.Throwable cause)
void
exposedButNotBound(Key<?> key)
static java.lang.String
format(java.lang.String messageFormat, java.lang.Object... arguments)
static java.lang.String
format(java.lang.String heading, java.util.Collection<Message> errorMessages)
Returns the formatted message for an exception with the specified messages.static void
formatInjectionPoint(java.util.Formatter formatter, Dependency<?> dependency, InjectionPoint injectionPoint)
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)
static java.lang.Throwable
getOnlyCause(java.util.Collection<Message> messages)
Returns the cause throwable if there is exactly one cause inmessages
.java.util.List<java.lang.Object>
getSources()
boolean
hasErrors()
Errors
merge(java.util.Collection<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(Key key)
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)
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)
int
size()
Errors
subtypeNotProvided(java.lang.Class<? extends Provider<?>> providerType, java.lang.Class<?> type)
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.
-
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);
-
converterReturnedNull
public Errors converterReturnedNull(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter)
-
conversionTypeError
public Errors conversionTypeError(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter, java.lang.Object converted)
-
conversionError
public Errors conversionError(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter, java.lang.RuntimeException cause)
-
ambiguousTypeConversion
public Errors ambiguousTypeConversion(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter a, MatcherAndConverter b)
-
bindingToProvider
public Errors bindingToProvider()
-
subtypeNotProvided
public Errors subtypeNotProvided(java.lang.Class<? extends 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(Scope 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)
-
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()
-
errorInjectingMethod
public Errors errorInjectingMethod(java.lang.Throwable cause)
-
errorNotifyingTypeListener
public Errors errorNotifyingTypeListener(TypeListenerBinding listener, TypeLiteral<?> type, java.lang.Throwable cause)
-
errorInjectingConstructor
public Errors errorInjectingConstructor(java.lang.Throwable cause)
-
errorInProvider
public Errors errorInProvider(java.lang.RuntimeException runtimeException)
-
errorInUserInjector
public Errors errorInUserInjector(MembersInjector<?> listener, TypeLiteral<?> type, java.lang.RuntimeException cause)
-
errorNotifyingInjectionListener
public Errors errorNotifyingInjectionListener(InjectionListener<?> listener, TypeLiteral<?> type, java.lang.RuntimeException cause)
-
exposedButNotBound
public void exposedButNotBound(Key<?> key)
-
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()
-
cannotSatisfyCircularDependency
public Errors cannotSatisfyCircularDependency(java.lang.Class<?> expectedType)
-
throwCreationExceptionIfErrorsExist
public void throwCreationExceptionIfErrorsExist()
-
throwConfigurationExceptionIfErrorsExist
public void throwConfigurationExceptionIfErrorsExist()
-
throwProvisionExceptionIfErrorsExist
public void throwProvisionExceptionIfErrorsExist()
-
getSources
public java.util.List<java.lang.Object> getSources()
-
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)
-
format
public static java.lang.String format(java.lang.String messageFormat, java.lang.Object... arguments)
-
getMessages
public java.util.List<Message> getMessages()
-
format
public static java.lang.String format(java.lang.String heading, java.util.Collection<Message> errorMessages)
Returns the formatted message for an exception with the specified messages.
-
checkForNull
public <T> T checkForNull(T value, java.lang.Object source, Dependency<?> dependency) throws ErrorsException
Returnsvalue
if it is non-null allowed to be null. Otherwise a message is added and anErrorsException
is thrown.- Throws:
ErrorsException
-
getOnlyCause
public static java.lang.Throwable getOnlyCause(java.util.Collection<Message> messages)
Returns the cause throwable if there is exactly one cause inmessages
. If there are zero or multiple messages with causes, null is returned.
-
size
public int size()
-
convert
public static java.lang.Object convert(java.lang.Object o)
-
formatSource
public static void formatSource(java.util.Formatter formatter, java.lang.Object source)
-
formatInjectionPoint
public static void formatInjectionPoint(java.util.Formatter formatter, Dependency<?> dependency, InjectionPoint injectionPoint)
-
-