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

dev.harrel.jsonschema.Draft2019EvaluatorFactory Maven / Gradle / Ivy

The newest version!
package dev.harrel.jsonschema;

import java.util.*;

import static dev.harrel.jsonschema.Keyword.*;
import static dev.harrel.jsonschema.Vocabulary.*;

/**
 * {@code EvaluatorFactory} implementation that supports 2019 draft specification.
 */
public class Draft2019EvaluatorFactory extends AbstractEvaluatorFactory {
    public Draft2019EvaluatorFactory() {
        super(getIgnoredKeywords(), createEvaluatorMap());
    }

    private static Set getIgnoredKeywords() {
        return new HashSet<>(Arrays.asList(ID, SCHEMA, ANCHOR, RECURSIVE_ANCHOR, VOCABULARY, COMMENT, DEFS, THEN, ELSE));
    }

    private static Map createEvaluatorMap() {
        Map map = createDefaultEvaluatorsMap(Draft2019.CORE, Draft2019.APPLICATOR, Draft2019.APPLICATOR, Draft2019.VALIDATION);
        map.put(RECURSIVE_REF, new EvaluatorInfo(Draft2019.CORE, (ctx, node) -> new RecursiveRefEvaluator(node)));
        map.put(ITEMS, new EvaluatorInfo(Draft2019.APPLICATOR, ItemsLegacyEvaluator::new));
        map.put(ADDITIONAL_ITEMS, new EvaluatorInfo(Draft2019.APPLICATOR, AdditionalItemsEvaluator::new));
        return map;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy