Package io.quarkiverse.loggingjson
Class JsonWritingUtils
- java.lang.Object
-
- io.quarkiverse.loggingjson.JsonWritingUtils
-
public class JsonWritingUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description JsonWritingUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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.
-
-
-
Method Detail
-
writeMapEntries
public static void writeMapEntries(JsonGenerator generator, Map<?,?> map) throws IOException
Writes entries of the map as fields.- Throws:
IOException
-
writeMapStringFields
public static void writeMapStringFields(JsonGenerator generator, String fieldName, Map<String,String> map) throws IOException
Writes 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 IOException
Writes 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
public static boolean isNotNullOrEmpty(String value)
-
-