Package io.quarkiverse.loggingjson
Class JsonWritingUtils
java.lang.Object
io.quarkiverse.loggingjson.JsonWritingUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisNotNullOrEmpty(String value) static voidwriteMapEntries(JsonGenerator generator, Map<?, ?> map) Writes entries of the map as fields.static voidwriteMapStringFields(JsonGenerator generator, String fieldName, Map<String, String> map) Writes a map as String fields to the generator if and only if the fieldName and values are not null.static voidwriteMapStringFields(JsonGenerator generator, String fieldName, Map<String, String> map, boolean lowerCaseKeys) Writes a map as String fields to the generator if and only if the fieldName and values are not null.static voidwriteNumberField(JsonGenerator generator, String fieldName, int fieldValue) Writes the field to the generator if and only if the fieldName is not null.static voidwriteNumberField(JsonGenerator generator, String fieldName, long fieldValue) Writes the field to the generator if and only if the fieldName is not null.static voidwriteStringArrayField(JsonGenerator generator, String fieldName, String[] fieldValues) Writes an array of strings to the generator if and only if the fieldName and values are not null.static voidwriteStringField(JsonGenerator generator, String fieldName, String fieldValue) Writes the field to the generator if and only if the fieldName and fieldValue are not null.
-
Constructor Details
-
JsonWritingUtils
public JsonWritingUtils()
-
-
Method Details
-
writeMapEntries
Writes entries of the map as fields.- Throws:
IOException
-
writeMapStringFields
public static void writeMapStringFields(JsonGenerator generator, String fieldName, Map<String, String> map) throws IOExceptionWrites a map as String fields to the generator if and only if the fieldName and values are not null.- Throws:
IOException
-
writeMapStringFields
public static void writeMapStringFields(JsonGenerator generator, String fieldName, Map<String, String> map, boolean lowerCaseKeys) throws IOExceptionWrites a map as String fields to the generator if and only if the fieldName and values are not null.- Parameters:
lowerCaseKeys- when true, the map keys will be written in lowercase.- Throws:
IOException
-
writeStringArrayField
public static void writeStringArrayField(JsonGenerator generator, String fieldName, String[] fieldValues) throws IOException Writes an array of strings to the generator if and only if the fieldName and values are not null.- Throws:
IOException
-
writeStringField
public static void writeStringField(JsonGenerator generator, String fieldName, String fieldValue) throws IOException Writes the field to the generator if and only if the fieldName and fieldValue are not null.- Throws:
IOException
-
writeNumberField
public static void writeNumberField(JsonGenerator generator, String fieldName, int fieldValue) throws IOException Writes the field to the generator if and only if the fieldName is not null.- Throws:
IOException
-
writeNumberField
public static void writeNumberField(JsonGenerator generator, String fieldName, long fieldValue) throws IOException Writes the field to the generator if and only if the fieldName is not null.- Throws:
IOException
-
isNotNullOrEmpty
-