Class Messages


  • public final class Messages
    extends java.lang.Object
    Utility methods for Message objects
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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.lang.String messageFormat, java.lang.Object... arguments)
      Creates a new Message with the given 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 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.
      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.
      static java.lang.Throwable getOnlyCause​(java.util.Collection<Message> messages)
      Returns the cause throwable if there is exactly one cause in messages.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • format

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

        public static Message create​(java.lang.Throwable cause,
                                     java.lang.String messageFormat,
                                     java.lang.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​(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:
        cause - The exception that caused the error
        sources - The binding sources for the source stack
        messageFormat - Format string
        arguments - format string arguments
      • getOnlyCause

        public static java.lang.Throwable getOnlyCause​(java.util.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.