com.h3c.util.health

## Class Health<C extends Enum<C>>

- java.lang.Object
- - com.h3c.util.health.Health<C>

- Type Parameters:
    `C` - the category enum
  All Implemented Interfaces:
    Encodable, Comparable<Health<C>>
  Direct Known Subclasses:
    DomainHealth, LocationHealth, VsnHealth

      public abstract class Health<C extends Enum<C>>
      extends Object
      implements Comparable<Health<C>>, Encodable

  A representation of the health of some "thing". Instances are composed of a "state" for each of an enumeration of categories, and an aggregated (derived) state for the "thing" as a whole. Note that the value for the aggregated state is computed externally (via a `StateAggregator` or some subclass) and set via the `setAggregateState(com.h3c.util.health.State)` method.

  A timestamp records when the aggregate state was last updated.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `Health()` Constructs an instance of Health.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(Health<C> o)` Compares this Health instance to the specified Health instance and returns a value consistent with the contract for Comparable.
    `boolean` | `equals(Object o)`
    `State` | `getAggregateState()` Returns the aggregate state.
    `protected abstract Class<C>` | `getCategoryEnumClass()` Subclasses must return the class of category enumeration that they parameterized themselves with.
    `State` | `getState(C category)` Returns the state for the specified category.
    `long` | `getTimestamp()` Returns the timestamp of when the aggregate state was last updated.
    `int` | `hashCode()`
    `void` | `setState(C category, State state)` Sets the specified state value for the given category.
    `String` | `toDebugString()` Returns a multi-line string representation useful for debugging.
    `String` | `toEncodedString()` Returns a string that is an encodement of this instance.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Health

          protected Health()

      Constructs an instance of Health. It has no "component" contributions, and an aggregate state of `State.UNKNOWN`.

  - ### Method Detail

    - #### getTimestamp

          public long getTimestamp()

      Returns the timestamp of when the aggregate state was last updated.
      Returns:
        the last updated timestamp

    - #### getAggregateState

          public State getAggregateState()

      Returns the aggregate state.
      Returns:
        the aggregate state

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### toDebugString

          public String toDebugString()

      Returns a multi-line string representation useful for debugging.
      Returns:
        a multi-line string representation

    - #### setState

          public void setState(C category,
                      State state)

      Sets the specified state value for the given category.
      Parameters:
        `category` - the category
        `state` - the state
      Throws:
        `NullPointerException` - if either category or state is null

    - #### getState

          public State getState(C category)

      Returns the state for the specified category. Note that the default value (for categories that don't have an explicitly set state) is `State.NORMAL`.
      Parameters:
        `category` - the required category
      Returns:
        that category's state
      Throws:
        `NullPointerException` - if category is null

    - #### compareTo

          public int compareTo(Health<C> o)

      Compares this Health instance to the specified Health instance and returns a value consistent with the contract for Comparable.

      This implementation compares the values in the `aggregate state` fields.

      Specified by:
        `compareTo` in interface `Comparable<Health<C extends Enum<C>>>`
      Parameters:
        `o` - the other status to compare to
      Returns:
        a value less than, equal to, or more than zero, as appropriate

    - #### toEncodedString

          public String toEncodedString()

      Description copied from interface: `Encodable`
      Returns a string that is an encodement of this instance.
      Specified by:
        `toEncodedString` in interface `Encodable`
      Returns:
        a string encodement of this instance

    - #### getCategoryEnumClass

          protected abstract Class<C> getCategoryEnumClass()

      Subclasses must return the class of category enumeration that they parameterized themselves with.
      Returns:
        the category enumeration class

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

Copyright © 2014. All Rights Reserved.