Package org.jsonschema2pojo
Class CompositeAnnotator
java.lang.Object
org.jsonschema2pojo.CompositeAnnotator
- All Implemented Interfaces:
Annotator
An annotator (implementing the composite pattern) that can be used to compose
many annotators together.
-
Constructor Summary
ConstructorsConstructorDescriptionCompositeAnnotator(Annotator... annotators) Create a new composite annotator, made up of a given set of child annotators. -
Method Summary
Modifier and TypeMethodDescriptionvoidadditionalPropertiesField(com.sun.codemodel.JFieldVar field, com.sun.codemodel.JDefinedClass clazz, String propertyName) Add the necessary annotations to the field that will hold 'additional' properties.voidanyGetter(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.voidanySetter(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.voiddateField(com.sun.codemodel.JFieldVar field, com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode propertyNode) Add the necessary annotations to a date field.voiddateTimeField(com.sun.codemodel.JFieldVar field, com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode propertyNode) Add the necessary annotations to a date-time field.voidenumConstant(com.sun.codemodel.JDefinedClass _enum, com.sun.codemodel.JEnumConstant constant, String value) Add the necessary annotations to an enum constant.voidenumCreatorMethod(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.voidenumValueMethod(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.booleanIndicates whether the annotation style that this annotator uses can support the JSON Schema 'additionalProperties' feature.booleanisPolymorphicDeserializationSupported(com.fasterxml.jackson.databind.JsonNode node) Indicates whether type hint annotations should be added to support polymorphic deserialization.voidpropertyField(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 propertyvoidpropertyGetter(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 propertyvoidpropertyInclusion(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.voidpropertyOrder(com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode propertiesNode) Add the necessary annotation to dictate correct property order during serializationvoidpropertySetter(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 propertyvoidtimeField(com.sun.codemodel.JFieldVar field, com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode propertyNode) Add the necessary annotations to a time field.voidtypeInfo(com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode node) Add the necessary annotation to dictate correct type information during serialization and deserialization; often required with polymorphic types.
-
Constructor Details
-
CompositeAnnotator
Create a new composite annotator, made up of a given set of child annotators.- Parameters:
annotators- The annotators that will be called whenever this annotator is called. The child annotators provided will called in the order that they appear in this argument list.
-
-
Method Details
-
typeInfo
public void typeInfo(com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode node) Description copied from interface:AnnotatorAdd the necessary annotation to dictate correct type information during serialization and deserialization; often required with polymorphic types. -
propertyOrder
public void propertyOrder(com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode propertiesNode) Description copied from interface:AnnotatorAdd the necessary annotation to dictate correct property order during serialization- Specified by:
propertyOrderin interfaceAnnotator- Parameters:
clazz- a generated pojo class, that needs serialization annotationspropertiesNode- the properties to be ordered
-
propertyInclusion
public void propertyInclusion(com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode schema) Description copied from interface:AnnotatorAdd the necessary annotation to cause only non-null values to be included during serialization.- Specified by:
propertyInclusionin interfaceAnnotator- Parameters:
clazz- a generated pojo class, that needs serialization annotationsschema- the object schema associated with this clazz
-
propertyField
public void propertyField(com.sun.codemodel.JFieldVar field, com.sun.codemodel.JDefinedClass clazz, String propertyName, com.fasterxml.jackson.databind.JsonNode propertyNode) Description copied from interface:AnnotatorAdd the necessary annotation to mark a Java field as a JSON property- Specified by:
propertyFieldin interfaceAnnotator- Parameters:
field- the field that contains data that will be serializedclazz- a generated pojo class, that needs serialization annotationspropertyName- the name of the JSON property that this field representspropertyNode- the schema node defining this property
-
propertyGetter
public void propertyGetter(com.sun.codemodel.JMethod getter, com.sun.codemodel.JDefinedClass clazz, String propertyName) Description copied from interface:AnnotatorAdd the necessary annotation to mark a Java method as the getter for a JSON property- Specified by:
propertyGetterin interfaceAnnotator- Parameters:
getter- the method that will be used to get the value of the given JSON propertyclazz- a generated pojo class, that needs serialization annotationspropertyName- the name of the JSON property that this getter gets
-
propertySetter
public void propertySetter(com.sun.codemodel.JMethod setter, com.sun.codemodel.JDefinedClass clazz, String propertyName) Description copied from interface:AnnotatorAdd the necessary annotation to mark a Java method as the setter for a JSON property- Specified by:
propertySetterin interfaceAnnotator- Parameters:
setter- the method that will be used to set the value of the given JSON propertyclazz- a generated pojo class, that needs serialization annotationspropertyName- the name of the JSON property that this setter sets
-
anyGetter
public void anyGetter(com.sun.codemodel.JMethod getter, com.sun.codemodel.JDefinedClass clazz) Description copied from interface:AnnotatorAdd 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. -
anySetter
public void anySetter(com.sun.codemodel.JMethod setter, com.sun.codemodel.JDefinedClass clazz) Description copied from interface:AnnotatorAdd 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. -
enumCreatorMethod
public void enumCreatorMethod(com.sun.codemodel.JDefinedClass _enum, com.sun.codemodel.JMethod creatorMethod) Description copied from interface:AnnotatorAdd 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.- Specified by:
enumCreatorMethodin interfaceAnnotator- Parameters:
_enum- a generated enum class, that needs serialization annotationscreatorMethod- the method that can create a Java enum value from a JSON value
-
enumValueMethod
public void enumValueMethod(com.sun.codemodel.JDefinedClass _enum, com.sun.codemodel.JMethod valueMethod) Description copied from interface:AnnotatorAdd 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.- Specified by:
enumValueMethodin interfaceAnnotator- Parameters:
_enum- a generated enum class, that needs serialization annotationsvalueMethod- the enum instance method that can create a JSON value during serialization
-
enumConstant
public void enumConstant(com.sun.codemodel.JDefinedClass _enum, com.sun.codemodel.JEnumConstant constant, String value) Description copied from interface:AnnotatorAdd the necessary annotations to an enum constant. For instance, to force the given value to be used when serializing.- Specified by:
enumConstantin interfaceAnnotator- Parameters:
_enum- a generated enum class, that needs serialization annotationsconstant- one of the constants within _enumvalue- the value to use when serializing this constant
-
isAdditionalPropertiesSupported
public boolean isAdditionalPropertiesSupported()Description copied from interface:AnnotatorIndicates whether the annotation style that this annotator uses can support the JSON Schema 'additionalProperties' feature. In other words, can the deserializer associated with this annotation style gather unexpected, additional json properties and does it expect to include them somewhere in the target Java instance.Jackson is able to use it's
JsonAnyGetterandJsonAnySetterfeatures for this purpose, hence for Jackson annotators, this method will returntrue. Gson does not support 'additional' property values (they are silently discarded at deserialization time), hence for Gson annotators, this method would returnfalse. Moshi 1.x behaves similar to Gson and therefore returnsfalse.- Specified by:
isAdditionalPropertiesSupportedin interfaceAnnotator- Returns:
- Whether this annotator has any way to support 'additional properties'.
-
additionalPropertiesField
public void additionalPropertiesField(com.sun.codemodel.JFieldVar field, com.sun.codemodel.JDefinedClass clazz, String propertyName) Description copied from interface:AnnotatorAdd the necessary annotations to the field that will hold 'additional' properties.- Specified by:
additionalPropertiesFieldin interfaceAnnotator- Parameters:
field- the field (usually a Map) that will hold properties that are not explicitly mentioned in the schemaclazz- a generated pojo class, that needs serialization annotationspropertyName- unused
-
isPolymorphicDeserializationSupported
public boolean isPolymorphicDeserializationSupported(com.fasterxml.jackson.databind.JsonNode node) Description copied from interface:AnnotatorIndicates whether type hint annotations should be added to support polymorphic deserialization.- Specified by:
isPolymorphicDeserializationSupportedin interfaceAnnotator- Parameters:
node- the relevant schema node- Returns:
trueif the JSON library supports polymorphic deserialization AND the deserializationClassProperty is present in this schema
-
dateTimeField
public void dateTimeField(com.sun.codemodel.JFieldVar field, com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode propertyNode) Description copied from interface:AnnotatorAdd the necessary annotations to a date-time field. For instance, to format the date-time in the expected style.- Specified by:
dateTimeFieldin interfaceAnnotator- Parameters:
field- the field that contains data that will be serializedclazz- a generated pojo class, that needs serialization annotationspropertyNode- the schema node defining this property
-
dateField
public void dateField(com.sun.codemodel.JFieldVar field, com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode propertyNode) Description copied from interface:AnnotatorAdd the necessary annotations to a date field. For instance, to format the date in the expected style. -
timeField
public void timeField(com.sun.codemodel.JFieldVar field, com.sun.codemodel.JDefinedClass clazz, com.fasterxml.jackson.databind.JsonNode propertyNode) Description copied from interface:AnnotatorAdd the necessary annotations to a time field. For instance, to format the time in the expected style.
-