All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xpertss.json.schema.processors.data.SchemaContext Maven / Gradle / Ivy

The newest version!
package xpertss.json.schema.processors.data;

import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.NodeType;
import xpertss.json.schema.core.report.MessageProvider;
import xpertss.json.schema.core.report.ProcessingMessage;
import xpertss.json.schema.core.tree.JsonTree;
import xpertss.json.schema.core.tree.SchemaTree;
import xpertss.json.schema.processors.digest.SchemaDigester;
import xpertss.json.schema.processors.validation.ValidationChain;

/**
 * Input for both a {@link SchemaDigester} and a {@link ValidationChain}
 *
 * 

This is essentially a {@link FullData} which only retains the type of the * instance to validate instead of the full instance.

* * @see NodeType#getNodeType(JsonNode) */ public final class SchemaContext implements MessageProvider { private final SchemaTree schema; private final NodeType instanceType; public SchemaContext(FullData data) { schema = data.getSchema(); final JsonTree tree = data.getInstance(); instanceType = tree != null ? NodeType.getNodeType(tree.getNode()) : null; } public SchemaContext(SchemaTree schema, NodeType instanceType) { this.schema = schema; this.instanceType = instanceType; } public SchemaTree getSchema() { return schema; } public NodeType getInstanceType() { return instanceType; } @Override public ProcessingMessage newMessage() { return new ProcessingMessage().put("schema", schema); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy