Top Description Fields Methods
io.micrometer.common

public Interface KeyValue

extends Comparable<KeyValue>
Known Direct Implementers
io.micrometer.common.ValidatedKeyValue, io.micrometer.common.ImmutableKeyValue
Imports
java.util.function.Function, .Predicate, io.micrometer.common.docs.KeyName

Key/value pair representing a dimension of a meter used to classify and drill into measurements.
Author
Jon Schneider
Since
1.10.0

Field Summary

Modifier and TypeField and Description
public static final String
NONE_VALUE

Use this if you want to indicate that the value is missing.

Method Summary

Modifier and TypeMethod and Description
public default int
compareTo(KeyValue
the object to be compared.
o
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.
public String
public String
public static KeyValue

Returns:

KeyValue
of
(String
key of the KeyValue
key
,
String
value for key
value
)

Creates a KeyValue for the given key and value.

public static KeyValue

Returns:

KeyValue
of
(KeyName
name of the key of the KeyValue
keyName
,
String
value for key
value
)

Creates a KeyValue for the given KeyName and value.

public static <E> KeyValue

Returns:

KeyValue
of
(E
the source element
element
,
Function<E, String>
function to extract the key from the element
keyExtractor
,
Function<E, String>
function to extract the value from the element
valueExtractor
)

Creates a KeyValue for the given element by extracting a key and value from it.

public static <T> KeyValue

Returns:

KeyValue
of
(String
key of the KeyValue
key
,
T
value for key
value
,
Predicate<? super T>
the Predicate used for validating the value
validator
)

Creates a KeyValue for the given key and value and additionally validates it with the Predicate.

public static <T> KeyValue

Returns:

KeyValue
of
(KeyName
name of the key of the KeyValue
keyName
,
T
value for key
value
,
Predicate<? super T>
the Predicate used for validating the value
validator
)

Creates a KeyValue for the given KeyName and value and additionally validates it with the Predicate.

Field Detail

NONE_VALUEback to summary
public static final String NONE_VALUE

Use this if you want to indicate that the value is missing.

Method Detail

compareToback to summary
public default int compareTo(KeyValue o)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
o:KeyValue

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
getKeyback to summary
public String getKey()
getValueback to summary
public String getValue()
ofback to summary
public static KeyValue of(String key, String value)

Creates a KeyValue for the given key and value.

Parameters
key:String

key of the KeyValue

value:String

value for key

Returns:KeyValue

KeyValue

ofback to summary
public static KeyValue of(KeyName keyName, String value)

Creates a KeyValue for the given KeyName and value.

Parameters
keyName:KeyName

name of the key of the KeyValue

value:String

value for key

Returns:KeyValue

KeyValue

ofback to summary
public static <E> KeyValue of(E element, Function<E, String> keyExtractor, Function<E, String> valueExtractor)

Creates a KeyValue for the given element by extracting a key and value from it.

Parameters
element:E

the source element

keyExtractor:Function<E, String>

function to extract the key from the element

valueExtractor:Function<E, String>

function to extract the value from the element

Returns:KeyValue

KeyValue

ofback to summary
public static <T> KeyValue of(String key, T value, Predicate<? super T> validator)

Creates a KeyValue for the given key and value and additionally validates it with the Predicate.

Parameters
key:String

key of the KeyValue

value:T

value for key

validator:Predicate<? super T>

the Predicate used for validating the value

Returns:KeyValue

KeyValue

ofback to summary
public static <T> KeyValue of(KeyName keyName, T value, Predicate<? super T> validator)

Creates a KeyValue for the given KeyName and value and additionally validates it with the Predicate.

Parameters
keyName:KeyName

name of the key of the KeyValue

value:T

value for key

validator:Predicate<? super T>

the Predicate used for validating the value

Returns:KeyValue

KeyValue