Package com.codahale.metrics.health
Class HealthCheck.Result
- java.lang.Object
-
- com.codahale.metrics.health.HealthCheck.Result
-
- Enclosing class:
- HealthCheck
public static class HealthCheck.Result extends java.lang.ObjectThe result of aHealthCheckbeing run. It can be healthy (with an optional message) or unhealthy (with either an error message or a thrown exception).
-
-
Constructor Summary
Constructors Modifier Constructor Description privateResult(boolean isHealthy, java.lang.String message, java.lang.Throwable error)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.lang.ThrowablegetError()Returns any exception for the result, ornullif the result has no exception.java.lang.StringgetMessage()Returns any additional message for the result, ornullif the result has no message.inthashCode()static HealthCheck.Resulthealthy()Returns a healthyHealthCheck.Resultwith no additional message.static HealthCheck.Resulthealthy(java.lang.String message)Returns a healthyHealthCheck.Resultwith an additional message.static HealthCheck.Resulthealthy(java.lang.String message, java.lang.Object... args)Returns a healthyHealthCheck.Resultwith a formatted message.booleanisHealthy()Returnstrueif the result indicates the component is healthy;falseotherwise.java.lang.StringtoString()static HealthCheck.Resultunhealthy(java.lang.String message)Returns an unhealthyHealthCheck.Resultwith the given message.static HealthCheck.Resultunhealthy(java.lang.String message, java.lang.Object... args)Returns an unhealthyHealthCheck.Resultwith a formatted message.static HealthCheck.Resultunhealthy(java.lang.Throwable error)Returns an unhealthyHealthCheck.Resultwith the given error.
-
-
-
Field Detail
-
HEALTHY
private static final HealthCheck.Result HEALTHY
-
PRIME
private static final int PRIME
- See Also:
- Constant Field Values
-
healthy
private final boolean healthy
-
message
private final java.lang.String message
-
error
private final java.lang.Throwable error
-
-
Method Detail
-
healthy
public static HealthCheck.Result healthy()
Returns a healthyHealthCheck.Resultwith no additional message.- Returns:
- a healthy
HealthCheck.Resultwith no additional message
-
healthy
public static HealthCheck.Result healthy(java.lang.String message)
Returns a healthyHealthCheck.Resultwith an additional message.- Parameters:
message- an informative message- Returns:
- a healthy
HealthCheck.Resultwith an additional message
-
healthy
public static HealthCheck.Result healthy(java.lang.String message, java.lang.Object... args)
Returns a healthyHealthCheck.Resultwith a formatted message. Message formatting follows the same rules asString.format(String, Object...).- Parameters:
message- a message formatargs- the arguments apply to the message format- Returns:
- a healthy
HealthCheck.Resultwith an additional message - See Also:
String.format(String, Object...)
-
unhealthy
public static HealthCheck.Result unhealthy(java.lang.String message)
Returns an unhealthyHealthCheck.Resultwith the given message.- Parameters:
message- an informative message describing how the health check failed- Returns:
- an unhealthy
HealthCheck.Resultwith the given message
-
unhealthy
public static HealthCheck.Result unhealthy(java.lang.String message, java.lang.Object... args)
Returns an unhealthyHealthCheck.Resultwith a formatted message. Message formatting follows the same rules asString.format(String, Object...).- Parameters:
message- a message formatargs- the arguments apply to the message format- Returns:
- an unhealthy
HealthCheck.Resultwith an additional message - See Also:
String.format(String, Object...)
-
unhealthy
public static HealthCheck.Result unhealthy(java.lang.Throwable error)
Returns an unhealthyHealthCheck.Resultwith the given error.- Parameters:
error- an exception thrown during the health check- Returns:
- an unhealthy
HealthCheck.Resultwith the given error
-
isHealthy
public boolean isHealthy()
Returnstrueif the result indicates the component is healthy;falseotherwise.- Returns:
trueif the result indicates the component is healthy
-
getMessage
public java.lang.String getMessage()
Returns any additional message for the result, ornullif 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, ornullif the result has no exception.- Returns:
- any exception for the result, or
null
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-