public final class Messages
extends java.lang.Object
Message
objectsModifier and Type | Class and Description |
---|---|
private static class |
Messages.Converter<T> |
private static class |
Messages.ThrowableEquivalence |
Modifier and Type | Field and Description |
---|---|
private static java.util.Collection<Messages.Converter<?>> |
converters |
Modifier | Constructor and Description |
---|---|
private |
Messages() |
Modifier and Type | Method and Description |
---|---|
private static java.lang.Object |
appendModules(java.lang.Object source,
ElementSource elementSource) |
(package private) static java.lang.Object |
convert(java.lang.Object o)
Formats an object in a user friendly way.
|
(package private) static java.lang.Object |
convert(java.lang.Object o,
ElementSource source) |
static Message |
create(java.lang.String messageFormat,
java.lang.Object... arguments)
Creates a new Message without a cause.
|
static Message |
create(java.lang.Throwable cause,
java.util.List<java.lang.Object> sources,
java.lang.String messageFormat,
java.lang.Object... arguments)
Creates a new Message with the given cause and a binding source stack.
|
static Message |
create(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... arguments)
Creates a new Message with the given cause.
|
static java.lang.String |
format(java.lang.String messageFormat,
java.lang.Object... arguments)
Calls
String.format(java.lang.String, java.lang.Object...) after converting the arguments using some standard guice formatting
for Key , Class and Member objects. |
private static void |
formatInjectionPoint(java.util.Formatter formatter,
Dependency<?> dependency,
InjectionPoint injectionPoint,
ElementSource elementSource) |
static java.lang.String |
formatMessages(java.lang.String heading,
java.util.Collection<Message> errorMessages)
Returns the formatted message for an exception with the specified messages.
|
(package private) static java.lang.String |
formatParameter(Dependency<?> dependency) |
(package private) static void |
formatSource(java.util.Formatter formatter,
java.lang.Object source) |
(package private) static void |
formatSource(java.util.Formatter formatter,
java.lang.Object source,
ElementSource elementSource) |
static java.lang.Throwable |
getOnlyCause(java.util.Collection<Message> messages)
Returns the cause throwable if there is exactly one cause in
messages . |
private static java.lang.String |
getOrdinalSuffix(int ordinal)
Maps
1 to the string "1st" ditto for all non-negative numbers |
(package private) static Message |
mergeSources(java.util.List<java.lang.Object> sources,
Message message)
Prepends the list of sources to the given
Message |
private static java.lang.String |
moduleSourceString(ElementSource elementSource) |
private static final java.util.Collection<Messages.Converter<?>> converters
static Message mergeSources(java.util.List<java.lang.Object> sources, Message message)
Message
public static java.lang.String format(java.lang.String messageFormat, java.lang.Object... arguments)
String.format(java.lang.String, java.lang.Object...)
after converting the arguments using some standard guice formatting
for Key
, Class
and Member
objects.public static java.lang.String formatMessages(java.lang.String heading, java.util.Collection<Message> errorMessages)
public static Message create(java.lang.String messageFormat, java.lang.Object... arguments)
messageFormat
- Format stringarguments
- format string argumentspublic static Message create(java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... arguments)
cause
- The exception that caused the errormessageFormat
- Format stringarguments
- format string argumentspublic static Message create(java.lang.Throwable cause, java.util.List<java.lang.Object> sources, java.lang.String messageFormat, java.lang.Object... arguments)
cause
- The exception that caused the errorsources
- The binding sources for the source stackmessageFormat
- Format stringarguments
- format string argumentsstatic java.lang.Object convert(java.lang.Object o)
static java.lang.Object convert(java.lang.Object o, ElementSource source)
private static java.lang.Object appendModules(java.lang.Object source, ElementSource elementSource)
private static java.lang.String moduleSourceString(ElementSource elementSource)
static void formatSource(java.util.Formatter formatter, java.lang.Object source)
static void formatSource(java.util.Formatter formatter, java.lang.Object source, ElementSource elementSource)
private static void formatInjectionPoint(java.util.Formatter formatter, Dependency<?> dependency, InjectionPoint injectionPoint, ElementSource elementSource)
static java.lang.String formatParameter(Dependency<?> dependency)
private static java.lang.String getOrdinalSuffix(int ordinal)
1
to the string "1st"
ditto for all non-negative numberspublic static java.lang.Throwable getOnlyCause(java.util.Collection<Message> messages)
messages
. If there are
zero or multiple messages with causes, null is returned.