Class StatusInfo

java.lang.Object
org.eclipse.ditto.internal.utils.health.StatusInfo
All Implemented Interfaces:
org.eclipse.ditto.base.model.json.Jsonifiable<org.eclipse.ditto.json.JsonObject>

@Immutable public final class StatusInfo extends Object implements org.eclipse.ditto.base.model.json.Jsonifiable<org.eclipse.ditto.json.JsonObject>
Contains the status and a detail in case the Status was not StatusInfo.Status.UP of a single health "entry".
  • Field Details

    • JSON_KEY_LABEL

      public static final org.eclipse.ditto.json.JsonFieldDefinition<String> JSON_KEY_LABEL
      JSON field of the label.
    • JSON_KEY_STATUS

      public static final org.eclipse.ditto.json.JsonFieldDefinition<String> JSON_KEY_STATUS
      JSON field of the status.
    • JSON_KEY_DETAILS

      public static final org.eclipse.ditto.json.JsonFieldDefinition<org.eclipse.ditto.json.JsonArray> JSON_KEY_DETAILS
      JSON field of the detailed status messages.
    • JSON_KEY_CHILDREN

      public static final org.eclipse.ditto.json.JsonFieldDefinition<org.eclipse.ditto.json.JsonArray> JSON_KEY_CHILDREN
      JSON field of the children (sub-statuses).
  • Method Details

    • unknown

      public static StatusInfo unknown()
      Returns a StatusInfo with status StatusInfo.Status.UNKNOWN.
      Returns:
      the StatusInfo instance.
    • fromStatus

      public static StatusInfo fromStatus(StatusInfo.Status status)
      Returns a new StatusInfo instance with the specified status.
      Parameters:
      status - the status.
      Returns:
      the StatusInfo instance.
    • fromStatus

      public static StatusInfo fromStatus(StatusInfo.Status status, @Nullable String message)
      Returns a new StatusInfo instance with the specified status and message.
      Parameters:
      status - the status.
      message - the message.
      Returns:
      the StatusInfo instance.
    • fromStatus

      public static StatusInfo fromStatus(StatusInfo.Status status, Collection<StatusDetailMessage> details)
      Returns a new StatusInfo instance with the specified status and details.
      Parameters:
      status - the status.
      details - the details.
      Returns:
      the StatusInfo instance.
    • fromDetail

      public static StatusInfo fromDetail(StatusDetailMessage detail)
      Returns a new StatusInfo instance with the specified detail. The status will be computed.
      Parameters:
      detail - the detail.
      Returns:
      the StatusInfo instance.
    • fromDetails

      public static StatusInfo fromDetails(Collection<StatusDetailMessage> details)
      Returns a new StatusInfo instance with the specified details. The status will be computed.
      Parameters:
      details - the detail.
      Returns:
      the StatusInfo instance.
    • composite

      public static StatusInfo composite(List<StatusInfo> children)
      Returns a new StatusInfo instance with the specified children. The composite status will be computed based on the children's statuses.
      Parameters:
      children - the children.
      Returns:
      the StatusInfo instance.
    • composite

      public static StatusInfo composite(Map<String,StatusInfo> labeledChildren)
      Returns a new StatusInfo instance with the specified labeledChildren. The map's key will label the StatusInfo values. The composite status will be computed based on the children's statuses.
      Parameters:
      labeledChildren - the children.
      Returns:
      the StatusInfo instance.
    • fromJson

      public static StatusInfo fromJson(String jsonString)
      Creates a new StatusInfo from a JSON string.
      Parameters:
      jsonString - the JSON string.
      Returns:
      the created instance.
      Throws:
      NullPointerException - if jsonString is null.
      IllegalArgumentException - if jsonString is empty.
      org.eclipse.ditto.json.JsonParseException - if the passed in jsonString does not contain a JSON object or if it is not valid JSON.
      org.eclipse.ditto.json.JsonMissingFieldException - if the passed in jsonObject was not in the expected format.
    • fromJson

      public static StatusInfo fromJson(org.eclipse.ditto.json.JsonObject jsonObject)
      Creates a new StatusInfo from a JSON object.
      Parameters:
      jsonObject - the JSON object.
      Returns:
      the created instance.
      Throws:
      NullPointerException - if jsonObject is null.
      IllegalArgumentException - if jsonObject is empty.
      org.eclipse.ditto.json.JsonMissingFieldException - if the passed in jsonObject was not in the expected format.
    • getStatus

      public StatusInfo.Status getStatus()
      Returns the Status.
      Returns:
      the status.
    • getDetails

      public List<StatusDetailMessage> getDetails()
      Returns the details.
      Returns:
      the details, which may be empty.
    • getChildren

      public List<StatusInfo> getChildren()
      Returns the children.
      Returns:
      the children, which may be empty.
      See Also:
    • getLabel

      public Optional<String> getLabel()
      Returns the (optional) label.
      Returns:
      the (optional) label.
    • label

      public StatusInfo label(@Nullable String label)
      Creates a copy of this instance with the given label as label.
      Parameters:
      label - the label, may be null.
      Returns:
      the labeled copy.
    • isComposite

      public boolean isComposite()
      Returns whether this instance is a composite, i.e. whether it has children.
      Returns:
      whether this instance is a composite.
      See Also:
    • addDetail

      public StatusInfo addDetail(StatusDetailMessage detail)
      Creates a new StatusInfo from this StatusInfo, extended with the specified detail. Note that adding an error detail might change the StatusInfo's status.
      Parameters:
      detail - the detail.
      Returns:
      the StatusInfo instance.
    • isHealthy

      public boolean isHealthy()
      Returns whether this status is considered as healthy.
      Returns:
      true, when healthy; false, otherwise.
    • toJson

      public org.eclipse.ditto.json.JsonObject toJson()
      Specified by:
      toJson in interface org.eclipse.ditto.base.model.json.Jsonifiable<org.eclipse.ditto.json.JsonObject>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object