## org.apache.hadoop.metrics2
Class Metric

    java.lang.Object
      org.apache.hadoop.metrics2.Metric

Direct Known Subclasses:
  MetricCounter, MetricGauge

    public abstract class Metric

extends Object

The immutable metric

Field Summary
`static String` `NO_DESCRIPTION`

Constructor Summary
`Metric(String name)` Construct the metric with name only
`Metric(String name, String desc)` Construct the metric with a name and a description

Method Summary
`String` `description()` Get the description of the metric
`boolean` `equals(Object obj)`
`int` `hashCode()`
`String` `name()` Get the name of the metric
`String` `toString()`
`abstract Number` `value()` Get the value of the metric
`abstract void` `visit(MetricsVisitor visitor)` Accept a visitor interface

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### NO_DESCRIPTION

    public static final String NO_DESCRIPTION

See Also:
  Constant Field Values

Constructor Detail

### Metric

    public Metric(String name)

  Construct the metric with name only

  Parameters:
    `name` - of the metric

### Metric

    public Metric(String name,
                  String desc)

  Construct the metric with a name and a description

  Parameters:
    `name` - of the metric
    `desc` - description of the metric

Method Detail

### name

    public String name()

  Get the name of the metric

  Returns:
    the name

### description

    public String description()

  Get the description of the metric

  Returns:
    the description

### value

    public abstract Number value()

  Get the value of the metric

  Returns:
    the value of the metric

### visit

    public abstract void visit(MetricsVisitor visitor)

  Accept a visitor interface

  Parameters:
    `visitor` - of the metric

### equals

    public boolean equals(Object obj)

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Copyright © 2009 The Apache Software Foundation