Class ELResolverChain

java.lang.Object
jakarta.el.ELResolver
jakarta.el.CompositeELResolver
io.micronaut.el.resolver.ELResolverChain

public final class ELResolverChain extends jakarta.el.CompositeELResolver
A CompositeELResolver that only consults, for an operation a resolver does not have to implement, the resolvers that implement it.

ELResolver.convertToType(ELContext, Object, Class) and ELResolver.invoke(ELContext, Object, Object, Class[], Object[]) have a default implementation that resolves nothing, and none of the resolvers of the specification overrides the former. The composite of the specification still asks every resolver on every coercion, which is the single largest cost of evaluating a compiled expression: the result of every value expression is coerced to its expected type. This composite records, when a resolver is added, whether its class overrides each of the two methods, and iterates only the resolvers that do. The semantics are the ones of CompositeELResolver: the resolvers are consulted in order until one sets propertyResolved.

Since:
1.0
Author:
Denis Stepanov
  • Constructor Details

    • ELResolverChain

      public ELResolverChain(jakarta.el.ELResolver... resolvers)
      Creates a chain of the given resolvers, in order.
      Parameters:
      resolvers - The resolvers
    • ELResolverChain

      public ELResolverChain(List<? extends jakarta.el.ELResolver> resolvers)
      Creates a chain of the given resolvers, in order.
      Parameters:
      resolvers - The resolvers
  • Method Details

    • add

      public void add(jakarta.el.ELResolver elResolver)
      Overrides:
      add in class jakarta.el.CompositeELResolver
    • converts

      public boolean converts()
      Returns:
      Whether any of the resolvers implements ELResolver.convertToType(ELContext, Object, Class)
    • getValue

      public @Nullable Object getValue(jakarta.el.ELContext context, @Nullable Object base, @Nullable Object property)
      Overrides:
      getValue in class jakarta.el.CompositeELResolver
    • getValueSandboxed

      @Internal public @Nullable Object getValueSandboxed(jakarta.el.ELContext context, Object base, @Nullable Object property)
      Resolves a property of a base object for an expression parsed at runtime. The resolvers are consulted as getValue(ELContext, Object, Object) consults them, and the ELSandbox of the context is asked about the base object before the first resolver that is not known to read it without reflection, and about the value such a resolver produced. The resolvers known to read without reflection are not held up by the sandbox at all.
      Parameters:
      context - The context
      base - The base object
      property - The property
      Returns:
      The value, when a resolver resolved it
    • setValueSandboxed

      @Internal public void setValueSandboxed(jakarta.el.ELContext context, Object base, @Nullable Object property, @Nullable Object value)
      Assigns a property of a base object for an expression parsed at runtime, consulting the ELSandbox of the context about the base object as getValueSandboxed(ELContext, Object, Object) does.
      Parameters:
      context - The context
      base - The base object
      property - The property
      value - The value
    • getTypeSandboxed

      @Internal public @Nullable Class<?> getTypeSandboxed(jakarta.el.ELContext context, Object base, @Nullable Object property)
      Resolves the type of a property of a base object for an expression parsed at runtime, consulting the ELSandbox of the context about the base object as getValueSandboxed(ELContext, Object, Object) does. The type is not a value the property holds, so it is not checked.
      Parameters:
      context - The context
      base - The base object
      property - The property
      Returns:
      The type, when a resolver resolved it
    • isReadOnlySandboxed

      @Internal public boolean isReadOnlySandboxed(jakarta.el.ELContext context, Object base, @Nullable Object property)
      Resolves whether a property of a base object is read only for an expression parsed at runtime, consulting the ELSandbox of the context about the base object as getValueSandboxed(ELContext, Object, Object) does.
      Parameters:
      context - The context
      base - The base object
      property - The property
      Returns:
      Whether the property is read only, when a resolver resolved it
    • convertToType

      public <T> @Nullable T convertToType(jakarta.el.ELContext context, @Nullable Object obj, @Nullable Class<T> targetType)
      Overrides:
      convertToType in class jakarta.el.CompositeELResolver
    • invoke

      public @Nullable Object invoke(jakarta.el.ELContext context, @Nullable Object base, @Nullable Object method, Class<?> @Nullable [] paramTypes, @Nullable Object[] params)
      Overrides:
      invoke in class jakarta.el.CompositeELResolver