Package org.jsonschema2pojo.rules
Class TypeRule
java.lang.Object
org.jsonschema2pojo.rules.TypeRule
- All Implemented Interfaces:
Rule<com.sun.codemodel.JClassContainer,com.sun.codemodel.JType>
public class TypeRule
extends Object
implements Rule<com.sun.codemodel.JClassContainer,com.sun.codemodel.JType>
Applies the "type" schema rule.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.sun.codemodel.JTypeapply(String nodeName, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode parent, com.sun.codemodel.JClassContainer jClassContainer, Schema schema) Applies this schema rule to take the required code generation steps.
-
Constructor Details
-
TypeRule
-
-
Method Details
-
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 jClassContainer, Schema schema) Applies this schema rule to take the required code generation steps.When applied, this rule reads the details of the given node to determine the appropriate Java type to return. This may be a newly generated type, it may be a primitive type or other type such as
StringorObject.JSON schema types and their Java type equivalent:
- "type":"any" =>
Object - "type":"array" => Either
SetorList, seeArrayRule - "type":"boolean" =>
boolean - "type":"integer" =>
int - "type":"null" =>
Object - "type":"number" =>
double - "type":"object" => Generated type (see
ObjectRule) - "type":"string" =>
String(or alternative based on presence of "format", seeFormatRule)
- Specified by:
applyin interfaceRule<com.sun.codemodel.JClassContainer,com.sun.codemodel.JType> - Parameters:
nodeName- the name of the node for which this "type" rule appliesnode- the node for which this "type" rule appliesparent- the parent nodejClassContainer- the package into which any newly generated type may be placedschema- the schema to which this schema rule (and the given node) belongs.- Returns:
- the Java type which, after reading the details of the given schema node, most appropriately matches the "type" specified
- "type":"any" =>
-