Class ConfigEvaluatorBuilder

java.lang.Object
org.pkl.config.java.ConfigEvaluatorBuilder

public final class ConfigEvaluatorBuilder extends Object
A builder for ConfigEvaluators.
  • Method Details

    • preconfigured

      public static ConfigEvaluatorBuilder preconfigured()
      Creates a builder with preconfigured module evaluator and value mapper builders.
    • unconfigured

      public static ConfigEvaluatorBuilder unconfigured()
      Creates a builder with unconfigured module evaluator and value mapper builders.
    • setEvaluatorBuilder

      public ConfigEvaluatorBuilder setEvaluatorBuilder(org.pkl.core.EvaluatorBuilder evaluatorBuilder)
      Sets the underlying module evaluator builder. When a config evaluator is built, the underlying module evaluator comes from this builder.
    • getEvaluatorBuilder

      public org.pkl.core.EvaluatorBuilder getEvaluatorBuilder()
      Returns the currently set module evaluator builder.
    • setValueMapperBuilder

      public ConfigEvaluatorBuilder setValueMapperBuilder(ValueMapperBuilder mapperBuilder)
      Sets the underlying value mapper builder. When a config evaluator is built, the underlying value mapper comes from this builder.
    • getValueMapperBuilder

      public ValueMapperBuilder getValueMapperBuilder()
      Returns the currently set value mapper builder.
    • addEnvironmentVariable

      public ConfigEvaluatorBuilder addEnvironmentVariable(String name, String value)
      Adds the given environment variable, overriding any environment variable previously added under the same name.

      Modules can read environment variables with read("env:<NAME>").

      This is a convenience method that delegates to the underlying evaluator builder.

    • addEnvironmentVariables

      public ConfigEvaluatorBuilder addEnvironmentVariables(Map<String,String> envVars)
      Adds the given environment variables, overriding any environment variables previously added under the same name.

      Modules can read environment variables with read("env:<NAME>").

      This is a convenience method that delegates to the underlying evaluator builder.

    • setEnvironmentVariables

      public ConfigEvaluatorBuilder setEnvironmentVariables(Map<String,String> envVars)
      Removes any existing environment variables, then adds the given environment variables.

      This is a convenience method that delegates to the underlying evaluator builder.

    • getEnvironmentVariables

      public Map<String,String> getEnvironmentVariables()
      Returns the currently set environment variables.

      This is a convenience method that delegates to the underlying evaluator builder.

    • addExternalProperty

      public ConfigEvaluatorBuilder addExternalProperty(String name, String value)
      Adds the given external property, overriding any property previously set under the same name.

      Modules can read external properties with read("prop:<name>").

      This is a convenience method that delegates to the underlying evaluator builder.

    • addExternalProperties

      public ConfigEvaluatorBuilder addExternalProperties(Map<String,String> properties)
      Adds the given external properties, overriding any properties previously set under the same name.

      Modules can read external properties with read("prop:<name>").

      This is a convenience method that delegates to the underlying evaluator builder.

    • setExternalProperties

      public ConfigEvaluatorBuilder setExternalProperties(Map<String,String> properties)
      Removes any existing external properties, then adds the given properties.

      This is a convenience method that delegates to the underlying evaluator builder.

    • getExternalProperties

      public Map<String,String> getExternalProperties()
      Returns the currently set external properties.

      This is a convenience method that delegates to the underlying evaluator builder.

    • setSecurityManager

      public ConfigEvaluatorBuilder setSecurityManager(org.pkl.core.SecurityManager manager)
      Sets the given security manager, replacing any previously set security manager.

      This is a convenience method that delegates to the underlying evaluator builder.

    • getSecurityManager

      @Nullable public @Nullable org.pkl.core.SecurityManager getSecurityManager()
      Returns the currently set security manager.

      This is a convenience method that delegates to the underlying evaluator builder.

    • setStackFrameTransformer

      public ConfigEvaluatorBuilder setStackFrameTransformer(org.pkl.core.StackFrameTransformer stackFrameTransformer)
      Sets the given stack frame transformer, replacing any previously set transformer.

      This is a convenience method that delegates to the underlying evaluator builder.

    • getStackFrameTransformer

      @Nullable public @Nullable org.pkl.core.StackFrameTransformer getStackFrameTransformer()
      Returns the currently set stack frame transformer.

      This is a convenience method that delegates to the underlying evaluator builder.

    • setProjectDependencies

      public ConfigEvaluatorBuilder setProjectDependencies(org.pkl.core.project.DeclaredDependencies dependencies)
      Sets the project for the evaluator, without applying evaluator settings in the project.

      This is a convenience method that delegates to the underlying evaluator builder.

    • applyFromProject

      public ConfigEvaluatorBuilder applyFromProject(org.pkl.core.project.Project project)
      Sets the project for the evaluator, and applies any settings if set.

      This is a convenience method that delegates to the underlying evaluator builder.

      Throws:
      IllegalStateException - if setSecurityManager(SecurityManager) was also called.
    • setTimeout

      public ConfigEvaluatorBuilder setTimeout(Duration timeout)
      Sets an evaluation timeout to be enforced by the ConfigEvaluator's evaluate methods.

      This is a convenience method that delegates to the underlying evaluator builder.

    • getTimeout

      @Nullable public @Nullable Duration getTimeout()
      Returns the currently set evaluation timeout.

      This is a convenience method that delegates to the underlying evaluator builder.

    • setAllowedModules

      public ConfigEvaluatorBuilder setAllowedModules(Collection<Pattern> patterns)
      Sets the set of URI patterns to be allowed when importing modules.

      This is a convenience method that delegates to the underlying evaluator builder.

      Throws:
      IllegalStateException - if setSecurityManager(SecurityManager) was also called.
    • getAllowedModules

      public List<Pattern> getAllowedModules()
      Returns the set of patterns to be allowed when importing modules.

      This is a convenience method that delegates to the underlying evaluator builder.

    • setAllowedResources

      public ConfigEvaluatorBuilder setAllowedResources(Collection<Pattern> patterns)
      Sets the set of URI patterns to be allowed when reading resources.

      This is a convenience method that delegates to the underlying evaluator builder.

      Throws:
      IllegalStateException - if setSecurityManager(SecurityManager) was also called.
    • getAllowedResources

      public List<Pattern> getAllowedResources()
      Returns the set of patterns to be allowed when reading resources.

      This is a convenience method that delegates to the underlying evaluator builder.

    • setRootDir

      public ConfigEvaluatorBuilder setRootDir(@Nullable @Nullable Path rootDir)
      Sets the root directory, which restricts access to file-based modules and resources located under this directory.

      This is a convenience method that delegates to the underlying evaluator builder.

    • getRootDir

      @Nullable public @Nullable Path getRootDir()
      Returns the currently set root directory, if set.

      This is a convenience method that delegates to the underlying evaluator builder.

    • setHttpClient

      public ConfigEvaluatorBuilder setHttpClient(org.pkl.core.http.HttpClient httpClient)
      Sets the HTTP Client to be used.

      Defaults to HttpClient.builder().buildLazily().

      Since:
      0.29.0
    • getHttpClient

      public org.pkl.core.http.HttpClient getHttpClient()
      Returns the currently set HTTP client.
      Since:
      0.29.0
    • build

      public ConfigEvaluator build()
      Builds a config evaluator whose underlying module evaluator and value mapper is built using the configured builders. The same builder can be used to build multiple config evaluators.