
com.araguacaima.commons.utils.jsonschema.ObjectRule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-utils Show documentation
Show all versions of commons-utils Show documentation
Common utilities is a set of java utilities for managing typical actions when working with enums,
files, exceptions, zip/jar files, classes (via Reflection), maps, numbers and so on.
Most of the utilities extend functionalities offered by amazing libraries such as:
* commons-beanutils (apache)
* commons-lang3 (apache)
* commons-io (apache)
* commons-math3 (apache)
* commons-collections4 (apache)
* jreversepro (akkumar)
package com.araguacaima.commons.utils.jsonschema;
import com.fasterxml.jackson.databind.JsonNode;
import com.sun.codemodel.JPackage;
import com.sun.codemodel.JType;
import org.jsonschema2pojo.Schema;
import org.jsonschema2pojo.rules.Rule;
import org.jsonschema2pojo.util.ParcelableHelper;
import org.jsonschema2pojo.util.ReflectionHelper;
import java.util.Map;
public class ObjectRule extends org.jsonschema2pojo.rules.ObjectRule {
private final RuleFactory ruleFactory;
protected ObjectRule(RuleFactory ruleFactory, ParcelableHelper parcelableHelper, ReflectionHelper reflectionHelper) {
super(ruleFactory, parcelableHelper, reflectionHelper);
this.ruleFactory = ruleFactory;
}
/**
* Applies this schema rule to take the required code generation steps.
*
* When this rule is applied for schemas of type object, the properties of
* the schema are used to generate a new Java class and determine its
* characteristics. See other implementers of {@link Rule} for details.
*/
@Override
public JType apply(String nodeName, JsonNode node, JsonNode parent, JPackage _package, Schema schema) {
Map generatedTypes = ruleFactory.getGeneratedTypes();
JType jType = generatedTypes.get(nodeName);
if (jType == null) {
jType = super.apply(nodeName, node, parent, _package, schema);
generatedTypes.put(nodeName, jType);
}
return jType;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy