com.holonplatform.core.internal

## Class DefaultExpressionResolverRegistry

- java.lang.Object
- - com.holonplatform.core.internal.DefaultExpressionResolverRegistry

- All Implemented Interfaces:
    ExpressionResolver.ExpressionResolverHandler, ExpressionResolver.ExpressionResolverProvider, ExpressionResolver.ExpressionResolverSupport, ExpressionResolverRegistry, Serializable

      public class DefaultExpressionResolverRegistry
      extends Object
      implements ExpressionResolverRegistry

  Default `ExpressionResolverRegistry` implementation.
  Since:
    5.0.0
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultExpressionResolverRegistry()` Contructor with cache enabled by default.
    `DefaultExpressionResolverRegistry(boolean cacheEnabled)` Contructor with cache enabling flag.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<E extends Expression,R extends Expression> void` | `addExpressionResolver(ExpressionResolver<E,R> expressionResolver)` Add an `ExpressionResolver`.
    `Iterable<ExpressionResolver>` | `getExpressionResolvers()` Get the available `ExpressionResolver`s.
    `<E extends Expression,R extends Expression> void` | `removeExpressionResolver(ExpressionResolver<E,R> expressionResolver)` Remove an `ExpressionResolver`.
    `<E extends Expression,R extends Expression> Optional<R>` | `resolve(E expression, Class<R> resolutionType, ExpressionResolver.ResolutionContext context)` Try to resolve given `expression` to obtain an `Expression` of the specified `resolutionType`, using the suitable `ExpressionResolver`s among all available resolvers for given expression and resolution type.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.holonplatform.core.ExpressionResolverRegistry

      `create, create`

    - ### Methods inherited from interface com.holonplatform.core.ExpressionResolver.ExpressionResolverSupport

      `addExpressionResolvers`

- - ### Constructor Detail

    - #### DefaultExpressionResolverRegistry

          public DefaultExpressionResolverRegistry()

      Contructor with cache enabled by default.

    - #### DefaultExpressionResolverRegistry

          public DefaultExpressionResolverRegistry(boolean cacheEnabled)

      Contructor with cache enabling flag.
      Parameters:
        `cacheEnabled` - Whether to enable the expression resolvers cache

  - ### Method Detail

    - #### addExpressionResolver

          public <E extends Expression,R extends Expression> void addExpressionResolver(ExpressionResolver<E,R> expressionResolver)

      Description copied from interface: `ExpressionResolver.ExpressionResolverSupport`
      Add an `ExpressionResolver`.
      Specified by:
        `addExpressionResolver` in interface `ExpressionResolver.ExpressionResolverSupport`
      Type Parameters:
        `E` - Expression type
        `R` - Resolved expression type
      Parameters:
        `expressionResolver` - Resolver to add (not null)

    - #### removeExpressionResolver

          public <E extends Expression,R extends Expression> void removeExpressionResolver(ExpressionResolver<E,R> expressionResolver)

      Description copied from interface: `ExpressionResolver.ExpressionResolverSupport`
      Remove an `ExpressionResolver`.
      Specified by:
        `removeExpressionResolver` in interface `ExpressionResolver.ExpressionResolverSupport`
      Type Parameters:
        `E` - Expression type
        `R` - Resolved expression type
      Parameters:
        `expressionResolver` - Resolver to remove (not null)

    - #### getExpressionResolvers

          public Iterable<ExpressionResolver> getExpressionResolvers()

      Description copied from interface: `ExpressionResolver.ExpressionResolverProvider`
      Get the available `ExpressionResolver`s.
      Specified by:
        `getExpressionResolvers` in interface `ExpressionResolver.ExpressionResolverProvider`
      Returns:
        the available `ExpressionResolver`s iterable (not null)

    - #### resolve

          public <E extends Expression,R extends Expression> Optional<R> resolve(E expression,
                                                                                 Class<R> resolutionType,
                                                                                 ExpressionResolver.ResolutionContext context)
                                                                          throws Expression.InvalidExpressionException

      Description copied from interface: `ExpressionResolver.ExpressionResolverHandler`
      Try to resolve given `expression` to obtain an `Expression` of the specified `resolutionType`, using the suitable `ExpressionResolver`s among all available resolvers for given expression and resolution type.

      `ExpressionResolver`s invokation order is defined relying on `Priority` annotation on resolvers class, if available.

      Specified by:
        `resolve` in interface `ExpressionResolver.ExpressionResolverHandler`
      Type Parameters:
        `E` - Expression type to resolve
        `R` - Resolved expression type
      Parameters:
        `expression` - Expression to resolve (not null)
        `resolutionType` - Type of the expression to obtain from resolvers (not null)
        `context` - Resolution context
      Returns:
        Optional resolved expression, empty if none of the suitable `ExpressionResolver`s, if any, resolved the expression
      Throws:
        `Expression.InvalidExpressionException` - If an error occurred during expression resolution

Copyright © 2019 The Holon Platform. All rights reserved.