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(String messageFormat, Object... arguments)
      Creates a new Message without a cause.
      Parameters:
      messageFormat - Format string
      arguments - format string arguments
    • create

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

      public static Message create(Throwable cause, List<Object> sources, String messageFormat, Object... arguments)
      Creates a new Message with the given cause and a binding source stack.
      Parameters:
      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)
    • moduleSourceString

      private static String moduleSourceString(ElementSource elementSource)
    • formatSource

      static void formatSource(Formatter formatter, Object source)
    • formatSource

      static void formatSource(Formatter formatter, Object source, ElementSource elementSource)
    • formatInjectionPoint

      private static void formatInjectionPoint(Formatter formatter, Dependency<?> dependency, InjectionPoint injectionPoint, ElementSource elementSource)
    • formatParameter

      static String formatParameter(Dependency<?> dependency)
    • getOrdinalSuffix

      private static String getOrdinalSuffix(int ordinal)
      Maps 1 to the string "1st" ditto for all non-negative numbers
      See Also:
    • 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.