dev.harrel.jsonschema.Draft2019EvaluatorFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of json-schema Show documentation
Show all versions of json-schema Show documentation
Library for JSON schema validation
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;
}
}