Class HealthCheck.Result

  • Enclosing interface:
    HealthCheck

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

      • isHealthy

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

        @Nullable
        public 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 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​(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​(String message,
                                                 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​(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​(String message,
                                                   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​(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​(String message,
                                                   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