From 1a12ce7cc706cabe73a6054dd29adaea8bc8c0a5 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Wed, 19 Oct 2022 00:06:21 +0900 Subject: [PATCH] Add KeyValue.of() variants for none values See gh-3458 --- .../java/io/micrometer/common/KeyValue.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/micrometer-commons/src/main/java/io/micrometer/common/KeyValue.java b/micrometer-commons/src/main/java/io/micrometer/common/KeyValue.java index 0d59132cc8..83fae2d3b8 100644 --- a/micrometer-commons/src/main/java/io/micrometer/common/KeyValue.java +++ b/micrometer-commons/src/main/java/io/micrometer/common/KeyValue.java @@ -57,6 +57,24 @@ static KeyValue of(KeyName keyName, String value) { return KeyValue.of(keyName.asString(), value); } + /** + * Creates a {@link KeyValue} for the given key and {@value NONE_VALUE}. + * @param key key of the KeyValue + * @return KeyValue + */ + static KeyValue of(String key) { + return of(key, NONE_VALUE); + } + + /** + * Creates a {@link KeyValue} for the given {@link KeyName} and {@value NONE_VALUE}. + * @param keyName name of the key of the KeyValue + * @return KeyValue + */ + static KeyValue of(KeyName keyName) { + return of(keyName, NONE_VALUE); + } + /** * Creates a {@link KeyValue} for the given key and value and additionally validates * it with the {@link Predicate}.