Class HealthStatus

  • All Implemented Interfaces:
    java.lang.Comparable<HealthStatus>

    @Introspected
    public class HealthStatus
    extends java.lang.Object
    implements java.lang.Comparable<HealthStatus>

    The status of a health indicator.

    Since:
    1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static HealthStatus DOWN
      Indicates the service is down and unavailable.
      static java.lang.String NAME_DOWN
      The default name to use for an DOWN status.
      static java.lang.String NAME_UP
      The default name to use for an UP status.
      static HealthStatus UNKNOWN
      Indicates the service status is unknown.
      static HealthStatus UP
      Indicates the service is operational.
    • Constructor Summary

      Constructors 
      Constructor Description
      HealthStatus​(@NotNull java.lang.String name)  
      HealthStatus​(java.lang.String name, java.lang.String description, java.lang.Boolean operational, java.lang.Integer severity)  
    • Field Detail

      • NAME_UP

        public static final java.lang.String NAME_UP
        The default name to use for an UP status.
        See Also:
        Constant Field Values
      • NAME_DOWN

        public static final java.lang.String NAME_DOWN
        The default name to use for an DOWN status.
        See Also:
        Constant Field Values
      • UP

        public static final HealthStatus UP
        Indicates the service is operational.
      • DOWN

        public static final HealthStatus DOWN
        Indicates the service is down and unavailable.
      • UNKNOWN

        public static final HealthStatus UNKNOWN
        Indicates the service status is unknown.
    • Constructor Detail

      • HealthStatus

        public HealthStatus​(java.lang.String name,
                            java.lang.String description,
                            java.lang.Boolean operational,
                            java.lang.Integer severity)
        Parameters:
        name - The name of the status
        description - The detailed information about the status
        operational - If it's operational
        severity - The severity, the higher the value, the more sever is situation.
      • HealthStatus

        public HealthStatus​(@NotNull
                            @NotNull java.lang.String name)
        Parameters:
        name - The name of the status
    • Method Detail

      • describe

        public HealthStatus describe​(java.lang.String description)
        Describe an existing HealthStatus.
        Parameters:
        description - The description
        Returns:
        The new health status
      • getName

        public java.lang.String getName()
        Returns:
        The name of the status
      • getDescription

        public java.util.Optional<java.lang.String> getDescription()
        Returns:
        The description of the status
      • getOperational

        public java.util.Optional<java.lang.Boolean> getOperational()
        Whether the status represents a functioning service.
        Returns:
        Empty if partially operational.
      • getSeverity

        public java.util.Optional<java.lang.Integer> getSeverity()
        The severity of the status. A higher severity indicates a more severe error.
        Returns:
        Empty if no severity specified.
      • 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
      • compareTo

        public int compareTo​(HealthStatus o)
        Sorts statuses in order of "functioning level". The most functional will appear first and the least functional will appear last.

        Operation is sorted (true, null, false). For statuses with matching operations, severity is sorted ascending, with nulls first.

        Specified by:
        compareTo in interface java.lang.Comparable<HealthStatus>
        Parameters:
        o - The status to compare
        Returns:
        -1, 1, or 0
      • toString

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