Skip to content

Commit

Permalink
perf: KeyValueParameter: Use a static JsonProvider.
Browse files Browse the repository at this point in the history
Change-Id: I8dcebfb6de16fcbb2b347ad03d40659a16647b74
  • Loading branch information
benkard committed Jul 5, 2024
1 parent a33e7ff commit a80482d
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -58,7 +60,7 @@ private KeyValueParameter(String key, JsonValue value) {
* @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));
}

/**
Expand All @@ -71,7 +73,7 @@ public static KeyValueParameter of(String key, String value) {
* @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));
}

/**
Expand All @@ -84,7 +86,7 @@ public static KeyValueParameter of(String key, int value) {
* @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));
}

/**
Expand All @@ -97,7 +99,7 @@ public static KeyValueParameter of(String key, long value) {
* @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));
}

/**
Expand All @@ -110,7 +112,7 @@ public static KeyValueParameter of(String key, double value) {
* @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));
}

/**
Expand All @@ -123,7 +125,7 @@ public static KeyValueParameter of(String key, BigDecimal value) {
* @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));
}

/**
Expand All @@ -141,7 +143,7 @@ public static KeyValueParameter of(String key, boolean value) {

@Override
public JsonObjectBuilder json() {
return Json.createObjectBuilder().add(key, value);
return JSON.createObjectBuilder().add(key, value);
}

/**
Expand Down

0 comments on commit a80482d

Please sign in to comment.