Class SpelParserConfiguration.Builder

java.lang.Object
org.springframework.expression.spel.SpelParserConfiguration.Builder
Enclosing class:
SpelParserConfiguration

public static final class SpelParserConfiguration.Builder extends Object
Fluent builder API for SpelParserConfiguration.

Each property defaults to the same value as the corresponding property in a SpelParserConfiguration created via the no-arg constructor — including honoring the system properties or Spring properties named "spring.expression.compiler.mode", "spring.expression.maxOperations", and "spring.expression.maxBigPowerBits" — with one exception: maximumAutoGrowSize defaults to 256 rather than Integer.MAX_VALUE, for consistency with the default auto-grow limit used for Spring's data binding support (see DataBinder.DEFAULT_AUTO_GROW_COLLECTION_LIMIT).

Only configure the properties that need to deviate from those defaults.

Since:
7.0.10
Author:
Juergen Hoeller, Phillip Webb, Andy Clement, Sam Brannen
See Also:
  • Method Details

    • compilerMode

      public SpelParserConfiguration.Builder compilerMode(SpelCompilerMode compilerMode)
      Set the compiler mode that parsers using this configuration should use.

      By default, set to the value configured via SpringProperties for a system property or Spring property named "spring.expression.compiler.mode", or SpelCompilerMode.OFF if that property is not set.

      WARNING: Enabling compilation for expressions from untrusted sources removes the safety guards supported in interpreted mode.

      Parameters:
      compilerMode - the compiler mode to use; must not be null
      See Also:
    • compilerClassLoader

      public SpelParserConfiguration.Builder compilerClassLoader(@Nullable ClassLoader compilerClassLoader)
      Set the ClassLoader to use as the basis for expression compilation.

      By default, set to null, indicating that the default ClassLoader should be used.

      Parameters:
      compilerClassLoader - the ClassLoader to use
    • autoGrowNullReferences

      public SpelParserConfiguration.Builder autoGrowNullReferences()
      Enable automatic growth of null references encountered while traversing a property path.

      By default, this is disabled.

    • autoGrowCollections

      public SpelParserConfiguration.Builder autoGrowCollections()
      Enable automatic growth of collections and arrays encountered while traversing a property path.

      By default, this is disabled.

      See Also:
    • maximumAutoGrowSize

      public SpelParserConfiguration.Builder maximumAutoGrowSize(int maximumAutoGrowSize)
      Set the maximum size to which a collection or array can automatically grow.

      By default, set to 256, for consistency with the default auto-grow limit used for Spring's data binding support (see DataBinder.DEFAULT_AUTO_GROW_COLLECTION_LIMIT) — unlike the constructors in SpelParserConfiguration, which default to Integer.MAX_VALUE (effectively unbounded) for backward compatibility.

      Parameters:
      maximumAutoGrowSize - the maximum auto-grow size; must not be negative, and a value of 0 effectively disables growing a collection or array beyond its current size
      See Also:
    • maximumExpressionLength

      public SpelParserConfiguration.Builder maximumExpressionLength(int maximumExpressionLength)
      Set the maximum length permitted for a SpEL expression.

      By default, set to SpelParserConfiguration.DEFAULT_MAX_EXPRESSION_LENGTH.

      Parameters:
      maximumExpressionLength - the maximum expression length; must be a positive number
    • maximumOperations

      public SpelParserConfiguration.Builder maximumOperations(int maximumOperations)
      Set the maximum number of operations permitted during SpEL expression evaluation.

      By default, set to the value configured via SpringProperties for a system property or Spring property named "spring.expression.maxOperations", or SpelParserConfiguration.DEFAULT_MAX_OPERATIONS if that property is not set.

      This limit applies to the number of operations performed — for example, operator evaluations, property accesses, method invocations, and each element processed by the selection and projection operators. It does not take into account the cost of an individual operation.

      Parameters:
      maximumOperations - the maximum number of operations; must be a positive number
    • maximumBigPowerBits

      public SpelParserConfiguration.Builder maximumBigPowerBits(int maximumBigPowerBits)
      Set the maximum number of bits permitted in the result of a BigDecimal or BigInteger power operation within a SpEL expression.

      By default, set to the value configured via SpringProperties for a system property or Spring property named "spring.expression.maxBigPowerBits", or SpelParserConfiguration.DEFAULT_MAX_BIG_POWER_BITS if that property is not set.

      Parameters:
      maximumBigPowerBits - the maximum number of bits; must be a positive number; use Integer.MAX_VALUE for no limit
    • build

      public SpelParserConfiguration build()
      Build the SpelParserConfiguration configured via this builder.