Class SchemaRule

java.lang.Object
org.jsonschema2pojo.rules.SchemaRule
All Implemented Interfaces:
Rule<com.sun.codemodel.JClassContainer,com.sun.codemodel.JType>

public class SchemaRule extends Object implements Rule<com.sun.codemodel.JClassContainer,com.sun.codemodel.JType>
Applies a JSON schema.
See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    SchemaRule(RuleFactory ruleFactory)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.sun.codemodel.JType
    apply(String nodeName, com.fasterxml.jackson.databind.JsonNode schemaNode, com.fasterxml.jackson.databind.JsonNode parent, com.sun.codemodel.JClassContainer generatableType, Schema schema)
    Applies this schema rule to take the required code generation steps.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SchemaRule

      protected SchemaRule(RuleFactory ruleFactory)
  • Method Details

    • apply

      public com.sun.codemodel.JType apply(String nodeName, com.fasterxml.jackson.databind.JsonNode schemaNode, com.fasterxml.jackson.databind.JsonNode parent, com.sun.codemodel.JClassContainer generatableType, Schema schema)
      Applies this schema rule to take the required code generation steps.

      At the root of a schema document this rule should be applied (schema documents contain a schema), but also in many places within the document. Each property of type "object" is itself defined by a schema, the items attribute of an array is a schema, the additionalProperties attribute of a schema is also a schema.

      Where the schema value is a $ref, the ref URI is assumed to be applicable as a URL (from which content will be read). Where the ref URI has been encountered before, the root Java type created by that schema will be re-used (generation steps won't be repeated).

      Specified by:
      apply in interface Rule<com.sun.codemodel.JClassContainer,com.sun.codemodel.JType>
      Parameters:
      schema - the schema within which this schema rule is being applied
      nodeName - the name of the JSON schema node
      schemaNode - the JSON schema node that has caused this rule to be applied
      parent - the JSON parent of node
      generatableType - A code generation construct to which this rule should be applied
      Returns:
      the newly generated source code item that was added/created as a result of executing this rule