org.altlinux.jabbix
Class JabbixMetric<T>

java.lang.Object
  extended by org.altlinux.jabbix.JabbixMetric<T>
Type Parameters:
T - the type of the metric value
Direct Known Subclasses:
JabbixActiveMetric

public class JabbixMetric<T>
extends Object

A metric, the named value representing certain parameter of a system.

Author:
Paul Wolneykien

Constructor Summary
JabbixMetric(String key, Class<T> type, T value)
          Constructs a new metric with the specified name and value type.
 
Method Summary
 boolean equals(Object o)
          Indicates whether some other object is "equal to" the metric.
 String getKey()
          Returns the name of the metric.
 T getValue()
          Returns the value of the metric.
 Class<T> getValueType()
          Returns a class for the value type of the metric.
 String toString()
          Returns the textual string representation of the value.
 void updateValue(Object value)
          Updates the value of the metric.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JabbixMetric

public JabbixMetric(String key,
                    Class<T> type,
                    T value)
Constructs a new metric with the specified name and value type.

Parameters:
key - the name of the metric
value - the value of the metric
Method Detail

getKey

public String getKey()
Returns the name of the metric.

Returns:
the name of the metric

getValue

public T getValue()
Returns the value of the metric.

Returns:
the value of the metric

updateValue

public void updateValue(Object value)
                 throws ClassCastException
Updates the value of the metric.

Parameters:
value - the new value
Throws:
ClassCastException - if type of the new value is incompatible with the value type of the metric
See Also:
MetricTable.updateMetric(JabbixMetric)

toString

public String toString()
Returns the textual string representation of the value. A special "null" value is returned in the case when the metric value is null.

Overrides:
toString in class Object

equals

public boolean equals(Object o)
Indicates whether some other object is "equal to" the metric. Two metrics are equal iff their keys are equal. A metric isn't equal to an object not derived from JabbixMetric.

Overrides:
equals in class Object

getValueType

public Class<T> getValueType()
Returns a class for the value type of the metric.

Returns:
a class for the value type of the metric