org.eclipse.microprofile.metrics

## Class MetricID

- java.lang.Object
- - org.eclipse.microprofile.metrics.MetricID

All Implemented Interfaces:
  Comparable<MetricID>

    public class MetricID
    extends Object
    implements Comparable<MetricID>

A unique identifier for `Metric` and `Metadata` that are registered in the `MetricRegistry` The MetricID contains:

- `Name`: (Required) The name of the metric.
- `Tags`: (Optional) The tags (represented by `Tag` objects) of the metric. The tag name must match the regex `[a-zA-Z_][a-zA-Z0-9_]*` (Ascii alphabet, numbers and underscore). The tag value may contain any UTF-8 encoded character.

### Constructor Summary

Constructors
Constructor and Description
`MetricID(String name)` Constructs a MetricID with the given metric name and no tags.
`MetricID(String name, Tag... tags)` Constructs a MetricID with the given metric name and `Tag`s.

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `compareTo(MetricID other)` Compares two MetricID objects through the following steps: Compares the names of the two MetricIDs lexicographically. If the names are equal: Compare the number of tags. If the tag lengths are equal: Compare the Tags (sorted by the Tag's key value) a) Compare the Tag names/keys lexicographically b) If keys are equal, compare the Tag values lexicographically
`boolean` `equals(Object o)`
`String` `getName()` Returns the Metric name associated with this MetricID
`Map<String,String>` `getTags()` Returns the underlying map containing the tags.
`Tag[]` `getTagsAsArray()` Gets the list of tags as an array of `Tag` objects.
`List<Tag>` `getTagsAsList()` Gets the list of tags as a list of `Tag` objects
`String` `getTagsAsString()` Gets the list of tags as a single String in the format 'key="value",key2="value2",...'
`int` `hashCode()`
`String` `toString()`

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

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

### Constructor Detail

#### MetricID

    public MetricID(String name)

Constructs a MetricID with the given metric name and no tags. If global tags are available then they will be appended to this MetricID.

Parameters:
  `name` - the name of the metric

#### MetricID

    public MetricID(String name,
                    Tag... tags)

Constructs a MetricID with the given metric name and `Tag`s. If global tags are available then they will be appended to this MetricID

Parameters:
  `name` - the name of the metric
  `tags` - the tags associated with this metric

### Method Detail

#### getName

    public String getName()

Returns the Metric name associated with this MetricID

Returns:
  the Metric name associated with this MetricID

#### getTags

    public Map<String,String> getTags()

Returns the underlying map containing the tags.

Returns:
  a `Map` of tags

#### getTagsAsString

    public String getTagsAsString()

Gets the list of tags as a single String in the format 'key="value",key2="value2",...'

Returns:
  a String containing the tags

#### getTagsAsList

    public List<Tag> getTagsAsList()

Gets the list of tags as a list of `Tag` objects

Returns:
  a a list of Tag objects

#### getTagsAsArray

    public Tag[] getTagsAsArray()

Gets the list of tags as an array of `Tag` objects.

Returns:
  An array of tags

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### compareTo

    public int compareTo(MetricID other)

Compares two MetricID objects through the following steps:

1. Compares the names of the two MetricIDs lexicographically.
2. If the names are equal: Compare the number of tags.
3. If the tag lengths are equal: Compare the Tags (sorted by the Tag's key value)
   - a) Compare the Tag names/keys lexicographically
   - b) If keys are equal, compare the Tag values lexicographically

Specified by:
  `compareTo` in interface `Comparable<MetricID>`
Parameters:
  `other` - the other MetricID