public abstract class AbstractAnnotator extends Object implements Annotator
Annotators that need the generation configuration should add a constructor
with GenerationConfig
arg. Annotators that don't need the
configuration need only add a default constructor.
Constructor and Description |
---|
AbstractAnnotator() |
AbstractAnnotator(GenerationConfig generationConfig) |
Modifier and Type | Method and Description |
---|---|
void |
additionalPropertiesField(com.sun.codemodel.JFieldVar field,
com.sun.codemodel.JDefinedClass clazz,
String propertyName) |
void |
anyGetter(com.sun.codemodel.JMethod getter,
com.sun.codemodel.JDefinedClass clazz)
Add the necessary annotation to mark a Java method as the getter for
additional JSON property values that do not match any of the other
property names found in the bean.
|
void |
anySetter(com.sun.codemodel.JMethod setter,
com.sun.codemodel.JDefinedClass clazz)
Add the necessary annotation to mark a Java method as the setter for
additional JSON property values that do not match any of the other
property names found in the bean.
|
void |
dateField(com.sun.codemodel.JFieldVar field,
com.sun.codemodel.JDefinedClass clazz,
com.fasterxml.jackson.databind.JsonNode node)
Add the necessary annotations to a date field.
|
void |
dateTimeField(com.sun.codemodel.JFieldVar field,
com.sun.codemodel.JDefinedClass clazz,
com.fasterxml.jackson.databind.JsonNode node)
Add the necessary annotations to a date-time field.
|
void |
enumConstant(com.sun.codemodel.JDefinedClass _enum,
com.sun.codemodel.JEnumConstant constant,
String value)
Add the necessary annotations to an enum constant.
|
void |
enumCreatorMethod(com.sun.codemodel.JDefinedClass _enum,
com.sun.codemodel.JMethod creatorMethod)
Add the necessary annotation to mark a static Java method as the
creator/factory method which can choose the correct Java enum value for a
given JSON value during deserialization.
|
void |
enumValueMethod(com.sun.codemodel.JDefinedClass _enum,
com.sun.codemodel.JMethod valueMethod)
Add the necessary annotation to mark a Java method as the value method
that is used to turn a Java enum value into a JSON value during
serialization.
|
GenerationConfig |
getGenerationConfig() |
boolean |
isAdditionalPropertiesSupported()
Indicates whether the annotation style that this annotator uses can
support the JSON Schema 'additionalProperties' feature.
|
boolean |
isPolymorphicDeserializationSupported(com.fasterxml.jackson.databind.JsonNode node) |
void |
propertyField(com.sun.codemodel.JFieldVar field,
com.sun.codemodel.JDefinedClass clazz,
String propertyName,
com.fasterxml.jackson.databind.JsonNode propertyNode)
Add the necessary annotation to mark a Java field as a JSON property
|
void |
propertyGetter(com.sun.codemodel.JMethod getter,
com.sun.codemodel.JDefinedClass clazz,
String propertyName)
Add the necessary annotation to mark a Java method as the getter for a
JSON property
|
void |
propertyInclusion(com.sun.codemodel.JDefinedClass clazz,
com.fasterxml.jackson.databind.JsonNode schema)
Add the necessary annotation to cause only non-null values to be included
during serialization.
|
void |
propertyOrder(com.sun.codemodel.JDefinedClass clazz,
com.fasterxml.jackson.databind.JsonNode propertiesNode)
Add the necessary annotation to dictate correct property order during
serialization
|
void |
propertySetter(com.sun.codemodel.JMethod setter,
com.sun.codemodel.JDefinedClass clazz,
String propertyName)
Add the necessary annotation to mark a Java method as the setter for a
JSON property
|
void |
timeField(com.sun.codemodel.JFieldVar field,
com.sun.codemodel.JDefinedClass clazz,
com.fasterxml.jackson.databind.JsonNode node)
Add the necessary annotations to a time field.
|
void |
typeInfo(com.sun.codemodel.JDefinedClass clazz,
com.fasterxml.jackson.databind.JsonNode schema)
Add the necessary annotation to dictate correct type information during
serialization and deserialization; often required with polymorphic types.
|
public AbstractAnnotator()
public AbstractAnnotator(GenerationConfig generationConfig)
public void typeInfo(com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode schema)
Annotator
typeInfo
in interface Annotator
clazz
- a generated pojo class, that is serialized to JSONschema
- the object schema associated with this clazzpublic void propertyOrder(com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode propertiesNode)
Annotator
propertyOrder
in interface Annotator
clazz
- a generated pojo class, that is serialized to JSONpropertiesNode
- the properties to be orderedpublic void propertyInclusion(com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode schema)
Annotator
propertyInclusion
in interface Annotator
clazz
- a generated pojo class, that is serialized to JSONschema
- the object schema associated with this clazzpublic void propertyField(com.sun.codemodel.JFieldVar field, com.sun.codemodel.JDefinedClass clazz, String propertyName, com.fasterxml.jackson.databind.JsonNode propertyNode)
Annotator
propertyField
in interface Annotator
field
- the field that contains data that will be serializedclazz
- the owner of the field (class to which the field belongs)propertyName
- the name of the JSON property that this field representspropertyNode
- the schema node defining this propertypublic void propertyGetter(com.sun.codemodel.JMethod getter, com.sun.codemodel.JDefinedClass clazz, String propertyName)
Annotator
propertyGetter
in interface Annotator
getter
- the method that will be used to get the value of the given
JSON propertypropertyName
- the name of the JSON property that this getter getspublic void propertySetter(com.sun.codemodel.JMethod setter, com.sun.codemodel.JDefinedClass clazz, String propertyName)
Annotator
propertySetter
in interface Annotator
setter
- the method that will be used to set the value of the given
JSON propertypropertyName
- the name of the JSON property that this setter setspublic void anyGetter(com.sun.codemodel.JMethod getter, com.sun.codemodel.JDefinedClass clazz)
Annotator
public void anySetter(com.sun.codemodel.JMethod setter, com.sun.codemodel.JDefinedClass clazz)
Annotator
public void enumCreatorMethod(com.sun.codemodel.JDefinedClass _enum, com.sun.codemodel.JMethod creatorMethod)
Annotator
enumCreatorMethod
in interface Annotator
creatorMethod
- the method that can create a Java enum value from a JSON valuepublic void enumValueMethod(com.sun.codemodel.JDefinedClass _enum, com.sun.codemodel.JMethod valueMethod)
Annotator
enumValueMethod
in interface Annotator
valueMethod
- the enum instance method that can create a JSON value during
serializationpublic void enumConstant(com.sun.codemodel.JDefinedClass _enum, com.sun.codemodel.JEnumConstant constant, String value)
Annotator
enumConstant
in interface Annotator
public boolean isAdditionalPropertiesSupported()
Annotator
Jackson is able to use it's JsonAnyGetter
and
JsonAnySetter
features for this purpose, hence for Jackson
annotators, this method will return true
. Gson does not
support 'additional' property values (they are silently discarded at
deserialization time), hence for Gson annotators, this method would
return false
. Moshi 1.x behaves similar to Gson and therefore
returns false
.
isAdditionalPropertiesSupported
in interface Annotator
public void additionalPropertiesField(com.sun.codemodel.JFieldVar field, com.sun.codemodel.JDefinedClass clazz, String propertyName)
additionalPropertiesField
in interface Annotator
public boolean isPolymorphicDeserializationSupported(com.fasterxml.jackson.databind.JsonNode node)
isPolymorphicDeserializationSupported
in interface Annotator
public GenerationConfig getGenerationConfig()
public void dateField(com.sun.codemodel.JFieldVar field, com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode node)
Annotator
public void timeField(com.sun.codemodel.JFieldVar field, com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode node)
Annotator
public void dateTimeField(com.sun.codemodel.JFieldVar field, com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode node)
Annotator
dateTimeField
in interface Annotator
field
- the field that contains data that will be serializednode
- the schema node defining this propertyCopyright © 2022. All rights reserved.