Class HealthCheck.Result

  • Enclosing interface:
    HealthCheck

    public static class HealthCheck.Result
    extends java.lang.Object
    The result of a health check. Instances can be created by one of the static methods of this class (e.g. healthy()).
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Throwable getError()
      The exception representing an unhealthy check, may be null.
      java.lang.String getMessage()
      Any message provided as part of the check, may be null.
      static HealthCheck.Result healthy()
      Creates a healthy result, with no message.
      static HealthCheck.Result healthy​(java.lang.String message)
      Creates a healthy result, with the given message.
      static HealthCheck.Result healthy​(java.lang.String message, java.lang.Object... args)
      Creates a healthy result, with the given message.
      boolean isHealthy()
      Was the component being checked healthy?
      static HealthCheck.Result unhealthy​(java.lang.String message)
      Creates an unhealthy result, with the given message.
      static HealthCheck.Result unhealthy​(java.lang.String message, java.lang.Object... args)
      Creates an unhealthy result, with the given message.
      static HealthCheck.Result unhealthy​(java.lang.String message, java.lang.Throwable error)
      Creates an unhealthy result, with the given exception and message.
      static HealthCheck.Result unhealthy​(java.lang.Throwable error)
      Creates an unhealthy result, with the given exception.
      • Methods inherited from class java.lang.Object

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

      • isHealthy

        public boolean isHealthy()
        Was the component being checked healthy?
        Returns:
        true if application component is healthy
      • getMessage

        @Nullable
        public java.lang.String getMessage()
        Any message provided as part of the check, may be null.

        A message may be provided with a healthy or unhealthy result.

        If getError() is non null, this message will be the message provided by that exception.

        Returns:
        any message provided as part of the check, may be null
      • getError

        @Nullable
        public java.lang.Throwable getError()
        The exception representing an unhealthy check, may be null.

        Healthy results will never have an associated error.

        Returns:
        the exception representing an unhealthy check, may be null
      • healthy

        public static HealthCheck.Result healthy()
        Creates a healthy result, with no message.
        Returns:
        a healthy result, with no message.
      • healthy

        public static HealthCheck.Result healthy​(java.lang.String message)
        Creates a healthy result, with the given message.
        Parameters:
        message - a message to accompany the result
        Returns:
        a healthy result, with the given message
      • healthy

        public static HealthCheck.Result healthy​(java.lang.String message,
                                                 java.lang.Object... args)
        Creates a healthy result, with the given message.

        The message is constructed by String.format(String, Object...) and the given arguments.

        Parameters:
        message - the message format strings
        args - values to be interpolated into the format string
        Returns:
        a healthy result, with the given message
      • unhealthy

        public static HealthCheck.Result unhealthy​(java.lang.String message)
        Creates an unhealthy result, with the given message.
        Parameters:
        message - a message to accompany the result
        Returns:
        an unhealthy result, with the given message
      • unhealthy

        public static HealthCheck.Result unhealthy​(java.lang.String message,
                                                   java.lang.Object... args)
        Creates an unhealthy result, with the given message.

        The message is constructed by String.format(String, Object...) and the given arguments.

        Parameters:
        message - the message format strings
        args - values to be interpolated into the format string
        Returns:
        an unhealthy result, with the given message
      • unhealthy

        public static HealthCheck.Result unhealthy​(java.lang.Throwable error)
        Creates an unhealthy result, with the given exception.

        The message of the given exception will also be used as the message of the result.

        Parameters:
        error - an exception thrown during health check
        Returns:
        an unhealthy result, with the given error
      • unhealthy

        public static HealthCheck.Result unhealthy​(java.lang.String message,
                                                   java.lang.Throwable error)
        Creates an unhealthy result, with the given exception and message.

        The supplied message will be used as the message of the result.

        Parameters:
        message - a message to accompany the result
        error - an exception thrown during health check
        Returns:
        an unhealthy result, with the given error and message
        Since:
        1.2