perf: KeyValueParameter: Use a static JsonProvider.
Change-Id: I8dcebfb6de16fcbb2b347ad03d40659a16647b74
diff --git a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/KeyValueParameter.java b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/KeyValueParameter.java
index 2ea4521..a2c468b 100644
--- a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/KeyValueParameter.java
+++ b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/KeyValueParameter.java
@@ -4,9 +4,9 @@
package eu.mulk.quarkus.googlecloud.jsonlogging;
-import jakarta.json.Json;
import jakarta.json.JsonObjectBuilder;
import jakarta.json.JsonValue;
+import jakarta.json.spi.JsonProvider;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Objects;
@@ -40,6 +40,8 @@
*/
public final class KeyValueParameter implements StructuredParameter {
+ private static final JsonProvider JSON = JsonProvider.provider();
+
private final String key;
private final JsonValue value;
@@ -58,7 +60,7 @@
* @return the newly constructed parameter, ready to be passed to a logging function.
*/
public static KeyValueParameter of(String key, String value) {
- return new KeyValueParameter(key, Json.createValue(value));
+ return new KeyValueParameter(key, JSON.createValue(value));
}
/**
@@ -71,7 +73,7 @@
* @return the newly constructed parameter, ready to be passed to a logging function.
*/
public static KeyValueParameter of(String key, int value) {
- return new KeyValueParameter(key, Json.createValue(value));
+ return new KeyValueParameter(key, JSON.createValue(value));
}
/**
@@ -84,7 +86,7 @@
* @return the newly constructed parameter, ready to be passed to a logging function.
*/
public static KeyValueParameter of(String key, long value) {
- return new KeyValueParameter(key, Json.createValue(value));
+ return new KeyValueParameter(key, JSON.createValue(value));
}
/**
@@ -97,7 +99,7 @@
* @return the newly constructed parameter, ready to be passed to a logging function.
*/
public static KeyValueParameter of(String key, double value) {
- return new KeyValueParameter(key, Json.createValue(value));
+ return new KeyValueParameter(key, JSON.createValue(value));
}
/**
@@ -110,7 +112,7 @@
* @return the newly constructed parameter, ready to be passed to a logging function.
*/
public static KeyValueParameter of(String key, BigDecimal value) {
- return new KeyValueParameter(key, Json.createValue(value));
+ return new KeyValueParameter(key, JSON.createValue(value));
}
/**
@@ -123,7 +125,7 @@
* @return the newly constructed parameter, ready to be passed to a logging function.
*/
public static KeyValueParameter of(String key, BigInteger value) {
- return new KeyValueParameter(key, Json.createValue(value));
+ return new KeyValueParameter(key, JSON.createValue(value));
}
/**
@@ -141,7 +143,7 @@
@Override
public JsonObjectBuilder json() {
- return Json.createObjectBuilder().add(key, value);
+ return JSON.createObjectBuilder().add(key, value);
}
/**