public class DynamicPropertiesRule extends Object implements Rule<com.sun.codemodel.JDefinedClass,com.sun.codemodel.JDefinedClass>
Modifier and Type | Field and Description |
---|---|
static String |
BUILDER_NAME |
static String |
DEFINED_GETTER_NAME |
static String |
DEFINED_SETTER_NAME |
static String |
GETTER_NAME |
static String |
NOT_FOUND_VALUE_FIELD |
static String |
SETTER_NAME |
Constructor and Description |
---|
DynamicPropertiesRule(RuleFactory ruleFactory) |
Modifier and Type | Method and Description |
---|---|
com.sun.codemodel.JDefinedClass |
apply(String nodeName,
com.fasterxml.jackson.databind.JsonNode node,
com.fasterxml.jackson.databind.JsonNode parent,
com.sun.codemodel.JDefinedClass jclass,
Schema currentSchema)
This rule adds dynamic getter, setter and builder methods based on the properties and additional properties
defined in a schema.
|
public static final String NOT_FOUND_VALUE_FIELD
public static final String SETTER_NAME
public static final String GETTER_NAME
public static final String BUILDER_NAME
public static final String DEFINED_SETTER_NAME
public static final String DEFINED_GETTER_NAME
public DynamicPropertiesRule(RuleFactory ruleFactory)
public com.sun.codemodel.JDefinedClass apply(String nodeName, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode parent, com.sun.codemodel.JDefinedClass jclass, Schema currentSchema)
If accessors are being generated, then methods for getting and setting properties by name will be added. These methods first attempt to call the appropriate getter or setter for the property. If the named property is not defined, then the additional properties map is used.
If builders are being generated, then a method for building properties by name will be added. This method first attempts to call the builder for the property. If no property with the supplied name is defined, then the additional properties map is used.
The methods generated by this class throw an IllegalArgumentException, if the name specified for the property is unknown and additional properties are not enabled. A ClassCastException will be thrown, when the value being set is incompatible with the type of the named property.
apply
in interface Rule<com.sun.codemodel.JDefinedClass,com.sun.codemodel.JDefinedClass>
nodeName
- the name of the node for which dynamic getters, setters, and builders are being added.node
- the properties node, containing property names and their
definitionparent
- the parent nodejclass
- the Java type which will have the given properties addedcurrentSchema
- the schema being implementedCopyright © 2022. All rights reserved.