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

com.zuunr.json.schema.validation.node.KeywordNode Maven / Gradle / Ivy

There is a newer version: 0.1.4
Show newest version
package com.zuunr.json.schema.validation.node;

import com.zuunr.json.JsonValue;
import com.zuunr.json.schema.JsonSchema;
import com.zuunr.json.schema.validation.ValidationContext;

/**
 * @author Niklas Eldberger
 */
public abstract class KeywordNode extends ValidationNode {


    public KeywordNode(JsonValue instance, JsonSchema schema, int keywordIndex, ValidationContext validationContext, JsonValue rootInstance) {
        super(instance, schema, keywordIndex, validationContext, rootInstance);
    }

    @Override
    protected final ValidationNode createFirstChildNode() {
        return null;
    }

    @Override
    protected final ValidationNode createNextChildNodeOfParent() {
        return ((SchemaNode) parentNode).createKeywordNode(keywordSchemaIndex() + 1);
    }

    @Override
    protected final void doAfterAllChildNodesAreCompleted() {
        // Nothing more to do
    }

    @Override
    protected void childNodeCompleted(ValidationNode subnode) {
        super.childNodeCompleted(subnode);
    }

    @Override
    protected JsonValue keyword() {
        return JsonValue.of(schema.getKeyword(keywordSchemaIndex(), instance)); // TODO: Refactor this for ok performance!!!!
    }

    @Override
    public Location location() {
        if (location == null) {
            location = new Location(
                    parentNode.location.instance,
                    parentNode.location.instanceProperty,
                    parentNode.location.keyword.add(keyword()),
                    schema.getKeyword(keyword().getString()));
        }
        return location;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy