Package io.apicurio.hub.api.codegen
Class JaxRsEnumRule
- java.lang.Object
-
- io.apicurio.hub.api.codegen.JaxRsEnumRule
-
- All Implemented Interfaces:
org.jsonschema2pojo.rules.Rule<com.sun.codemodel.JClassContainer,com.sun.codemodel.JType>
public class JaxRsEnumRule extends Object implements org.jsonschema2pojo.rules.Rule<com.sun.codemodel.JClassContainer,com.sun.codemodel.JType>
- Author:
- eric.wittmann@gmail.com
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedJaxRsEnumRule(org.jsonschema2pojo.rules.RuleFactory ruleFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.sun.codemodel.JTypeapply(String nodeName, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode parent, com.sun.codemodel.JClassContainer container, org.jsonschema2pojo.Schema schema)Applies this schema rule to take the required code generation steps.protected StringgetConstantName(String nodeName, String customName)
-
-
-
Method Detail
-
apply
public com.sun.codemodel.JType apply(String nodeName, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode parent, com.sun.codemodel.JClassContainer container, org.jsonschema2pojo.Schema schema)
Applies this schema rule to take the required code generation steps.A Java
Enumis 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.- Specified by:
applyin interfaceorg.jsonschema2pojo.rules.Rule<com.sun.codemodel.JClassContainer,com.sun.codemodel.JType>- Parameters:
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 added- Returns:
- the newly generated Java type that was created to represent the given enum
- See Also:
Rule.apply(java.lang.String, com.fasterxml.jackson.databind.JsonNode, com.fasterxml.jackson.databind.JsonNode, java.lang.Object, org.jsonschema2pojo.Schema)
-
-