public class GsonAnnotator extends AbstractAnnotator
SerializedName
annotation, we
are able to preserve the original format. Use this in conjunction with
GenerationConfig.getPropertyWordDelimiters()
to filter out underscores
or other unwanted delimiters but still marshal/unmarshal the same content.Constructor and Description |
---|
GsonAnnotator() |
Modifier and Type | Method and Description |
---|---|
void |
enumConstant(com.sun.codemodel.JEnumConstant constant,
String value)
Add the necessary annotations to an enum constant.
|
boolean |
isAdditionalPropertiesSupported()
Indicates whether the annotation style that this annotator uses can
support the JSON Schema 'additionalProperties' feature.
|
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
|
additionalPropertiesField, anyGetter, anySetter, enumCreatorMethod, enumValueMethod, propertyGetter, propertyInclusion, propertyOrder, propertySetter
public 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
propertyField
in class AbstractAnnotator
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 enumConstant(com.sun.codemodel.JEnumConstant constant, String value)
Annotator
enumConstant
in interface Annotator
enumConstant
in class AbstractAnnotator
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
.
isAdditionalPropertiesSupported
in interface Annotator
isAdditionalPropertiesSupported
in class AbstractAnnotator
Copyright © 2016. All rights reserved.