Class HealthCheck.Result

  • Enclosing class:
    HealthCheck

    public static class HealthCheck.Result
    extends java.lang.Object
    The result of a HealthCheck being run. It can be healthy (with an optional message) or unhealthy (with either an error message or a thrown exception).
    • Field Detail

      • healthy

        private final boolean healthy
      • message

        private final java.lang.String message
      • error

        private final java.lang.Throwable error
    • Constructor Detail

      • Result

        private Result​(boolean isHealthy,
                       java.lang.String message,
                       java.lang.Throwable error)
    • Method Detail

      • healthy

        public static HealthCheck.Result healthy​(java.lang.String message,
                                                 java.lang.Object... args)
        Returns a healthy HealthCheck.Result with a formatted message.

        Message formatting follows the same rules as String.format(String, Object...).

        Parameters:
        message - a message format
        args - the arguments apply to the message format
        Returns:
        a healthy HealthCheck.Result with an additional message
        See Also:
        String.format(String, Object...)
      • unhealthy

        public static HealthCheck.Result unhealthy​(java.lang.String message)
        Returns an unhealthy HealthCheck.Result with the given message.
        Parameters:
        message - an informative message describing how the health check failed
        Returns:
        an unhealthy HealthCheck.Result with the given message
      • unhealthy

        public static HealthCheck.Result unhealthy​(java.lang.String message,
                                                   java.lang.Object... args)
        Returns an unhealthy HealthCheck.Result with a formatted message.

        Message formatting follows the same rules as String.format(String, Object...).

        Parameters:
        message - a message format
        args - the arguments apply to the message format
        Returns:
        an unhealthy HealthCheck.Result with an additional message
        See Also:
        String.format(String, Object...)
      • unhealthy

        public static HealthCheck.Result unhealthy​(java.lang.Throwable error)
        Returns an unhealthy HealthCheck.Result with the given error.
        Parameters:
        error - an exception thrown during the health check
        Returns:
        an unhealthy HealthCheck.Result with the given error
      • isHealthy

        public boolean isHealthy()
        Returns true if the result indicates the component is healthy; false otherwise.
        Returns:
        true if the result indicates the component is healthy
      • getMessage

        public java.lang.String getMessage()
        Returns any additional message for the result, or null if the result has no message.
        Returns:
        any additional message for the result, or null
      • getError

        public java.lang.Throwable getError()
        Returns any exception for the result, or null if the result has no exception.
        Returns:
        any exception for the result, or null
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object