| Modifier | Constructor and Description |
|---|---|
protected |
EnumRule(RuleFactory ruleFactory) |
| Modifier and Type | Method and Description |
|---|---|
JType |
apply(String nodeName,
JsonNode node,
JClassContainer container,
Schema schema)
Applies this schema rule to take the required code generation steps.
|
protected String |
getConstantName(String nodeName,
String customName) |
protected EnumRule(RuleFactory ruleFactory)
public JType apply(String nodeName, JsonNode node, JClassContainer container, Schema schema)
A Java Enum is created, with constants for each of the enum
values present in the schema. The enum name is derived from the nodeName,
and the enum type itself is created as an inner class of the owning type.
In the rare case that no owning type exists (the enum is the root of the
schema), then the enum becomes a public class in its own right.
The actual JSON value for each enum constant is held in a property called
"value" in the generated type. A static factory method
fromValue(String) is added to the generated enum, and the
methods are annotated to allow Jackson to marshal/unmarshal values
correctly.
apply in interface Rule<JClassContainer,JType>nodeName - the name of the property which is an "enum"node - the enum nodecontainer - the class container (class or package) to which this enum
should be addedschema - the schema to which this schema rule (and the given node)
belongs.Copyright © 2017. All rights reserved.