Package io.gorules.zen
Class ZenEngineBuilder
java.lang.Object
io.gorules.zen.ZenEngineBuilder
Builder for creating ZenEngineWrapper instances with fluent API.
ZenEngineWrapper engine = ZenEngineBuilder.create()
.withFilesystemLoader("/app/decisions")
.withCaching(true)
.build();
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the ZenEngineWrapper instance.static ZenEngineBuildercreate()Create a new builder instance.withApiLoader(ApiLoaderConfig config) Use API loader with full configuration.withApiLoader(String baseUrl) Use API loader with given base URL.withApiLoader(String baseUrl, String bearerToken) Use API loader with given base URL and Bearer token.withCaching(boolean enable) Enable or disable decision caching.withClasspathLoader(String rootPath) Use classpath loader with given root path.withFilesystemLoader(String rootPath) Use filesystem loader with given root directory.withLoader(DecisionLoader loader) Use a custom decision loader.withMaxDepth(int maxDepth) Set maximum evaluation depth.Use in-memory loader.withTracing(boolean enable) Enable or disable tracing by default.
-
Method Details
-
create
Create a new builder instance.- Returns:
- New ZenEngineBuilder
-
withFilesystemLoader
Use filesystem loader with given root directory.- Parameters:
rootPath- Root directory containing decision files- Returns:
- this builder
-
withClasspathLoader
Use classpath loader with given root path.- Parameters:
rootPath- Root classpath path (e.g., "decisions/" or "/decisions/")- Returns:
- this builder
-
withMemoryLoader
Use in-memory loader. Decisions must be added programmatically.- Returns:
- this builder
-
withApiLoader
Use API loader with given base URL. Loads decisions from HTTP API.- Parameters:
baseUrl- Base URL for API (e.g., "https://api.example.com/decisions")- Returns:
- this builder
-
withApiLoader
Use API loader with given base URL and Bearer token. Convenience method for common authentication pattern.- Parameters:
baseUrl- Base URL for APIbearerToken- Bearer token for Authorization header- Returns:
- this builder
-
withApiLoader
Use API loader with full configuration. Allows complete control over headers, timeout, retries, etc.- Parameters:
config- API loader configuration- Returns:
- this builder
-
withLoader
Use a custom decision loader.- Parameters:
loader- Custom loader implementation- Returns:
- this builder
-
withCaching
Enable or disable decision caching.- Parameters:
enable- true to enable caching- Returns:
- this builder
-
withMaxDepth
Set maximum evaluation depth.- Parameters:
maxDepth- Maximum depth (default: 5)- Returns:
- this builder
-
withTracing
Enable or disable tracing by default.- Parameters:
enable- true to enable tracing- Returns:
- this builder
-
build
Build the ZenEngineWrapper instance.- Returns:
- configured ZenEngineWrapper
-