public final class Errors
extends java.lang.Object
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.
Constructor and Description |
---|
Errors() |
Errors(java.lang.Object source) |
Modifier and Type | Method and Description |
---|---|
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,
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)
Returns
value 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 heading,
java.util.Collection<Message> errorMessages)
Returns the formatted message for an exception with the specified messages.
|
static java.lang.String |
format(java.lang.String messageFormat,
java.lang.Object... arguments) |
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 in
messages . |
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 uses
source as a reference point for newly added errors. |
public Errors withSource(java.lang.Object source)
source
as a reference point for newly added errors.public Errors missingImplementation(Key key)
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.public Errors converterReturnedNull(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter)
public Errors conversionTypeError(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter, java.lang.Object converted)
public Errors conversionError(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter, java.lang.RuntimeException cause)
public Errors ambiguousTypeConversion(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter a, MatcherAndConverter b)
public Errors bindingToProvider()
public Errors subtypeNotProvided(java.lang.Class<? extends Provider<?>> providerType, java.lang.Class<?> type)
public Errors notASubtype(java.lang.Class<?> implementationType, java.lang.Class<?> type)
public Errors recursiveImplementationType()
public Errors recursiveProviderType()
public Errors missingRuntimeRetention(java.lang.Object source)
public Errors missingScopeAnnotation()
public Errors optionalConstructor(java.lang.reflect.Constructor constructor)
public Errors cannotBindToGuiceType(java.lang.String simpleName)
public Errors scopeNotFound(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation)
public Errors scopeAnnotationOnAbstractType(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation, java.lang.Class<?> type, java.lang.Object source)
public Errors misplacedBindingAnnotation(java.lang.reflect.Member member, java.lang.annotation.Annotation bindingAnnotation)
public Errors missingConstructor(java.lang.Class<?> implementation)
public Errors tooManyConstructors(java.lang.Class<?> implementation)
public Errors duplicateScopes(Scope existing, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, Scope scope)
public Errors voidProviderMethod()
public Errors missingConstantValues()
public Errors cannotInjectInnerClass(java.lang.Class<?> type)
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)
public Errors duplicateScopeAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation> a, java.lang.Class<? extends java.lang.annotation.Annotation> b)
public Errors recursiveBinding()
public Errors errorInjectingMethod(java.lang.Throwable cause)
public Errors errorNotifyingTypeListener(TypeListenerBinding listener, TypeLiteral<?> type, java.lang.Throwable cause)
public Errors errorInjectingConstructor(java.lang.Throwable cause)
public Errors errorInProvider(java.lang.RuntimeException runtimeException)
public Errors errorInUserInjector(MembersInjector<?> listener, TypeLiteral<?> type, java.lang.RuntimeException cause)
public Errors errorNotifyingInjectionListener(InjectionListener<?> listener, TypeLiteral<?> type, java.lang.RuntimeException cause)
public void exposedButNotBound(Key<?> key)
public static java.util.Collection<Message> getMessagesFromThrowable(java.lang.Throwable throwable)
public Errors errorInUserCode(java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... arguments)
public Errors cannotInjectRawProvider()
public Errors cannotInjectRawMembersInjector()
public Errors cannotInjectTypeLiteralOf(java.lang.reflect.Type unsupportedType)
public Errors cannotInjectRawTypeLiteral()
public Errors cannotSatisfyCircularDependency(java.lang.Class<?> expectedType)
public void throwCreationExceptionIfErrorsExist()
public void throwConfigurationExceptionIfErrorsExist()
public void throwProvisionExceptionIfErrorsExist()
public java.util.List<java.lang.Object> getSources()
public void throwIfNewErrors(int expectedSize) throws ErrorsException
ErrorsException
public ErrorsException toException()
public boolean hasErrors()
public Errors addMessage(java.lang.String messageFormat, java.lang.Object... arguments)
public static java.lang.String format(java.lang.String messageFormat, java.lang.Object... arguments)
public java.util.List<Message> getMessages()
public static java.lang.String format(java.lang.String heading, java.util.Collection<Message> errorMessages)
public <T> T checkForNull(T value, java.lang.Object source, Dependency<?> dependency) throws ErrorsException
value
if it is non-null allowed to be null. Otherwise a message is added and
an ErrorsException
is thrown.ErrorsException
public static java.lang.Throwable getOnlyCause(java.util.Collection<Message> messages)
messages
. If there are
zero or multiple messages with causes, null is returned.public int size()
public static java.lang.Object convert(java.lang.Object o)
public static void formatSource(java.util.Formatter formatter, java.lang.Object source)
public static void formatInjectionPoint(java.util.Formatter formatter, Dependency<?> dependency, InjectionPoint injectionPoint)