Class Messages

java.lang.Object
com.google.inject.internal.Messages

public final class Messages extends Object
Utility methods for Message objects
  • Field Details

  • Constructor Details

    • Messages

      private Messages()
  • Method Details

    • mergeSources

      static Message mergeSources(List<Object> sources, Message message)
      Prepends the list of sources to the given Message
    • format

      public static String format(String messageFormat, 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.
    • formatMessages

      public static String formatMessages(String heading, Collection<Message> errorMessages)
      Returns the formatted message for an exception with the specified messages.
    • create

      public static Message create(ErrorId errorId, String messageFormat, Object... arguments)
      Creates a new Message without a cause.
      Parameters:
      errorId - The enum id for the error
      messageFormat - Format string
      arguments - format string arguments
    • create

      public static Message create(ErrorId errorId, Throwable cause, String messageFormat, Object... arguments)
      Creates a new Message with the given cause.
      Parameters:
      errorId - The enum id for the error
      cause - The exception that caused the error
      messageFormat - Format string
      arguments - format string arguments
    • create

      public static Message create(ErrorId errorId, Throwable cause, List<Object> sources, String messageFormat, Object... arguments)
      Creates a new Message with the given cause and a binding source stack.
      Parameters:
      errorId - The enum id for the error
      cause - The exception that caused the error
      sources - The binding sources for the source stack
      messageFormat - Format string
      arguments - format string arguments
    • convert

      static Object convert(Object o)
      Formats an object in a user friendly way.
    • convert

      static Object convert(Object o, ElementSource source)
    • appendModules

      private static Object appendModules(Object source, ElementSource elementSource)
    • getOnlyCause

      public static Throwable getOnlyCause(Collection<Message> messages)
      Returns the cause throwable if there is exactly one cause in messages. If there are zero or multiple messages with causes, null is returned.
    • formatText

      private static final String formatText(String text, Messages.FormatOptions... options)
    • bold

      public static final String bold(String text)
    • redBold

      public static final String redBold(String text)
    • underline

      public static final String underline(String text)
    • faint

      public static final String faint(String text)