Package com.google.inject.internal
Class Messages
- java.lang.Object
-
- com.google.inject.internal.Messages
-
public final class Messages extends java.lang.Object
Utility methods forMessage
objects
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Messages.Converter<T>
private static class
Messages.FormatOptions
private static class
Messages.ThrowableEquivalence
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Collection<Messages.Converter<?>>
converters
-
Constructor Summary
Constructors Modifier Constructor Description private
Messages()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.Object
appendModules(java.lang.Object source, ElementSource elementSource)
static java.lang.String
bold(java.lang.String text)
(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(ErrorId errorId, java.lang.String messageFormat, java.lang.Object... arguments)
Creates a new Message without a cause.static Message
create(ErrorId errorId, java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... arguments)
Creates a new Message with the given cause.static Message
create(ErrorId errorId, 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 java.lang.String
faint(java.lang.String text)
static java.lang.String
format(java.lang.String messageFormat, java.lang.Object... arguments)
CallsString.format(java.lang.String, java.lang.Object...)
after converting the arguments using some standard guice formatting forKey
,Class
andMember
objects.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.private static java.lang.String
formatText(java.lang.String text, Messages.FormatOptions... options)
static java.lang.Throwable
getOnlyCause(java.util.Collection<Message> messages)
Returns the cause throwable if there is exactly one cause inmessages
.(package private) static Message
mergeSources(java.util.List<java.lang.Object> sources, Message message)
Prepends the list of sources to the givenMessage
static java.lang.String
redBold(java.lang.String text)
static java.lang.String
underline(java.lang.String text)
-
-
-
Field Detail
-
converters
private static final java.util.Collection<Messages.Converter<?>> converters
-
-
Method Detail
-
mergeSources
static Message mergeSources(java.util.List<java.lang.Object> sources, Message message)
Prepends the list of sources to the givenMessage
-
format
public static java.lang.String format(java.lang.String messageFormat, java.lang.Object... arguments)
CallsString.format(java.lang.String, java.lang.Object...)
after converting the arguments using some standard guice formatting forKey
,Class
andMember
objects.
-
formatMessages
public 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.
-
create
public static Message create(ErrorId errorId, java.lang.String messageFormat, java.lang.Object... arguments)
Creates a new Message without a cause.- Parameters:
errorId
- The enum id for the errormessageFormat
- Format stringarguments
- format string arguments
-
create
public static Message create(ErrorId errorId, java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... arguments)
Creates a new Message with the given cause.- Parameters:
errorId
- The enum id for the errorcause
- The exception that caused the errormessageFormat
- Format stringarguments
- format string arguments
-
create
public static Message create(ErrorId errorId, 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.- Parameters:
errorId
- The enum id for the errorcause
- The exception that caused the errorsources
- The binding sources for the source stackmessageFormat
- Format stringarguments
- format string arguments
-
convert
static java.lang.Object convert(java.lang.Object o)
Formats an object in a user friendly way.
-
convert
static java.lang.Object convert(java.lang.Object o, ElementSource source)
-
appendModules
private static java.lang.Object appendModules(java.lang.Object source, ElementSource elementSource)
-
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.
-
formatText
private static final java.lang.String formatText(java.lang.String text, Messages.FormatOptions... options)
-
bold
public static final java.lang.String bold(java.lang.String text)
-
redBold
public static final java.lang.String redBold(java.lang.String text)
-
underline
public static final java.lang.String underline(java.lang.String text)
-
faint
public static final java.lang.String faint(java.lang.String text)
-
-