diff --git a/qendpoint-store/src/main/java/com/the_qa_company/qendpoint/compiler/CompiledSail.java b/qendpoint-store/src/main/java/com/the_qa_company/qendpoint/compiler/CompiledSail.java index 20df439e..2da9c13c 100644 --- a/qendpoint-store/src/main/java/com/the_qa_company/qendpoint/compiler/CompiledSail.java +++ b/qendpoint-store/src/main/java/com/the_qa_company/qendpoint/compiler/CompiledSail.java @@ -80,13 +80,24 @@ private CompiledSail(CompiledSailCompiler config) throws IOException, SailCompil files = Objects.requireNonNullElseGet(config.endpointFiles, () -> new EndpointFiles(Path.of("native-store"), Path.of("hdt-store"), "index_dev.hdt")); } + SailCompiler sailCompiler = new SailCompiler(); + + // load the validator if (config.validator != null) { sailCompiler.setValidator(config.validator); } + + // register custom strings sailCompiler.registerDirObject(files); config.stringObject.forEach(sailCompiler::registerDirObject); config.stringConfig.forEach(sailCompiler::registerDirString); + + // register custom configs + if (config.sailCompilerConfig != null) { + config.sailCompilerConfig.config(sailCompiler); + } + LuceneSailCompiler luceneCompiler = (LuceneSailCompiler) sailCompiler .getCompiler(SailCompilerSchema.LUCENE_TYPE); @@ -354,6 +365,7 @@ public static class CompiledSailCompiler { private final List stringObject = new ArrayList<>(); private CompiledSailOptions options; private SailCompilerValidator validator; + private SailCompilerConfig sailCompilerConfig; private CompiledSailCompiler() { } @@ -481,6 +493,18 @@ public CompiledSailCompiler withValidator(SailCompilerValidator validator) { return this; } + /** + * set the config for the sail compiler + * + * @param config the config + * @return this + * @throws java.lang.NullPointerException a parameter is null + */ + public CompiledSailCompiler withCompilerConfig(SailCompilerConfig config) { + this.sailCompilerConfig = Objects.requireNonNull(config, "config can't be null!"); + return this; + } + /** * set a source sail to wrap with this compiled sail * diff --git a/qendpoint-store/src/main/java/com/the_qa_company/qendpoint/compiler/SailCompilerConfig.java b/qendpoint-store/src/main/java/com/the_qa_company/qendpoint/compiler/SailCompilerConfig.java new file mode 100644 index 00000000..fabbf3b5 --- /dev/null +++ b/qendpoint-store/src/main/java/com/the_qa_company/qendpoint/compiler/SailCompilerConfig.java @@ -0,0 +1,18 @@ +package com.the_qa_company.qendpoint.compiler; + +import java.io.IOException; + +/** + * Config option for the {@link SailCompiler}. + * + * @author Antoine Willerval + */ +public interface SailCompilerConfig { + /** + * Config the sail compiler + * + * @param compiler compiler + * @throws IOException io exception + */ + void config(SailCompiler compiler) throws IOException; +}