Class AnnotationJsonSerializer
java.lang.Object
net.jacobpeterson.jet.openapiannotationsplugin.gson.serializer.annotation.AnnotationJsonSerializer
- All Implemented Interfaces:
com.google.gson.JsonSerializer<Annotation>
@NullMarked
public class AnnotationJsonSerializer
extends Object
implements com.google.gson.JsonSerializer<Annotation>
AnnotationJsonSerializer is a JsonSerializer for Annotation that uses reflection to invoke
the Class.getDeclaredMethods() of the Annotation.annotationType() and uses reflection to handle
SerializedName, AnnotationJsonIgnore, AnnotationJsonSerializeEmptyArray,
AnnotationJsonObjectInline, AnnotationArrayIsNullableValue, AnnotationJsonRawString,
AnnotationArrayIsMap, and AnnotationArrayIsMapKey.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe delimiter as described byCURRENT_ANNOTATION_METHOD:"#"static final ThreadLocal<@Nullable Method> static final StringThe JSON key name forgetTracerClasses():"__AnnotationJsonSerializer.JSON_KEY_CLASS_TRACER__"static final StringThe JSON key name forCURRENT_ANNOTATION_METHOD:"__AnnotationJsonSerializer.JSON_KEY_METHOD_TRACER__" -
Constructor Summary
ConstructorsConstructorDescriptionAnnotationJsonSerializer(Set<Class<? extends Annotation>> tracerClasses) Creates a newAnnotationJsonSerializerinstance. -
Method Summary
Modifier and TypeMethodDescriptionSet<Class<? extends Annotation>> TheSetofAnnotationClasses to insert aJSON_KEY_CLASS_TRACERproperty into the serializedJsonObjectwith the value ofClass.getCanonicalName().static voidremoveTracers(com.google.gson.JsonObject jsonObject) com.google.gson.JsonElementserialize(Annotation src, Type typeOfSrc, com.google.gson.JsonSerializationContext context)
-
Field Details
-
JSON_KEY_CLASS_TRACER
The JSON key name forgetTracerClasses():"__AnnotationJsonSerializer.JSON_KEY_CLASS_TRACER__"- See Also:
-
JSON_KEY_METHOD_TRACER
The JSON key name forCURRENT_ANNOTATION_METHOD:"__AnnotationJsonSerializer.JSON_KEY_METHOD_TRACER__"- See Also:
-
ANNOTATION_METHOD_CLASS_NAME_DELIMITER
The delimiter as described byCURRENT_ANNOTATION_METHOD:"#"- See Also:
-
CURRENT_ANNOTATION_METHOD
TheThreadLocalMethodof the currentAnnotationbeing serialized. If set and theAnnotation.annotationType()being serialized is ingetTracerClasses(), then a property with the key ofJSON_KEY_METHOD_TRACERand a value of the concatenation ofClass.getCanonicalName(),ANNOTATION_METHOD_CLASS_NAME_DELIMITER, andMethod.getName()is added to the serializedJsonObject.
-
-
Constructor Details
-
AnnotationJsonSerializer
Creates a newAnnotationJsonSerializerinstance.- Parameters:
tracerClasses- TheSetofAnnotationClasses to insert aJSON_KEY_CLASS_TRACERproperty into the serializedJsonObjectwith the value ofClass.getCanonicalName().
-
-
Method Details
-
removeTracers
public static void removeTracers(com.google.gson.JsonObject jsonObject) - Parameters:
jsonObject- theJsonObject
-
serialize
public com.google.gson.JsonElement serialize(Annotation src, Type typeOfSrc, com.google.gson.JsonSerializationContext context) - Specified by:
serializein interfacecom.google.gson.JsonSerializer<Annotation>
-
getTracerClasses
TheSetofAnnotationClasses to insert aJSON_KEY_CLASS_TRACERproperty into the serializedJsonObjectwith the value ofClass.getCanonicalName().
-