Class ConfigEvaluatorBuilder


  • public final class ConfigEvaluatorBuilder
    extends java.lang.Object
    A builder for ConfigEvaluators.
    • Method Detail

      • 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​(java.lang.String name,
                                                             java.lang.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​(java.util.Map<java.lang.String,​java.lang.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​(java.util.Map<java.lang.String,​java.lang.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 java.util.Map<java.lang.String,​java.lang.String> getEnvironmentVariables()
        Returns the currently set environment variables.

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

      • addExternalProperty

        public ConfigEvaluatorBuilder addExternalProperty​(java.lang.String name,
                                                          java.lang.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​(java.util.Map<java.lang.String,​java.lang.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​(java.util.Map<java.lang.String,​java.lang.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 java.util.Map<java.lang.String,​java.lang.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

        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

        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:
        java.lang.IllegalStateException - if setSecurityManager(SecurityManager) was also called.
      • setTimeout

        public ConfigEvaluatorBuilder setTimeout​(java.time.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.

      • setAllowedModules

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

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

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

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

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

      • setAllowedResources

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

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

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

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

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

      • setRootDir

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

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

      • getRootDir

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

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

      • getTimeout

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

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

      • 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.