private Processor<SchemaContext, ValidatorList> buildProcessor() { final RefResolver resolver = new RefResolver(loader); final Map<JsonRef, Library> libraries = validationCfg.getLibraries(); final Library defaultLibrary = validationCfg.getDefaultLibrary(); final ValidationChain defaultChain = new ValidationChain(resolver, defaultLibrary, validationCfg); final ProcessorMap<JsonRef, SchemaContext, ValidatorList> map = new ProcessorMap<JsonRef, SchemaContext, ValidatorList>(FUNCTION); map.setDefaultProcessor(defaultChain); JsonRef ref; ValidationChain chain; for (final Map.Entry<JsonRef, Library> entry: libraries.entrySet()) { ref = entry.getKey(); chain = new ValidationChain(resolver, entry.getValue(), validationCfg); map.addEntry(ref, chain); } final Processor<SchemaContext, ValidatorList> processor = map.getProcessor(); return new CachingProcessor<SchemaContext, ValidatorList>(processor, SchemaContextEquivalence.getInstance(), validationCfg.getCacheSize()); } }
public ValidationChain(final RefResolver refResolver, final Library library, final ValidationConfiguration cfg) { final SyntaxProcessor syntaxProcessor = new SyntaxProcessor( cfg.getSyntaxMessages(), library.getSyntaxCheckers()); final ProcessorChain<ValueHolder<SchemaTree>, ValueHolder<SchemaTree>> chain1 = ProcessorChain.startWith(refResolver).chainWith(syntaxProcessor); resolver = new CachingProcessor<ValueHolder<SchemaTree>, ValueHolder<SchemaTree>>( chain1.getProcessor(), SchemaHolderEquivalence.INSTANCE, cfg.getCacheSize() ); final SchemaDigester digester = new SchemaDigester(library); final ValidatorBuilder keywordBuilder = new ValidatorBuilder(library); ProcessorChain<SchemaContext, ValidatorList> chain2 = ProcessorChain.startWith(digester).chainWith(keywordBuilder); if (cfg.getUseFormat()) { final FormatProcessor format = new FormatProcessor(library, cfg); chain2 = chain2.chainWith(format); } builder = new CachingProcessor<SchemaContext, ValidatorList>( chain2.getProcessor(), SchemaContextEquivalence.getInstance(), cfg.getCacheSize() ); }