com.holonplatform.datastore.mongo.core.context

## Interface MongoResolutionContext<S extends com.mongodb.session.ClientSession>

- Type Parameters:
    `S` - Concrete ClientSession type
  All Superinterfaces:
    com.holonplatform.core.ExpressionResolver.ExpressionResolverHandler, com.holonplatform.core.ExpressionResolver.ExpressionResolverProvider, com.holonplatform.core.ExpressionResolver.ExpressionResolverSupport, com.holonplatform.core.ExpressionResolver.ResolutionContext, MongoContext<S>
  All Known Subinterfaces:
    MongoDocumentContext<S>

      public interface MongoResolutionContext<S extends com.mongodb.session.ClientSession>
      extends MongoContext<S>, com.holonplatform.core.ExpressionResolver.ResolutionContext, com.holonplatform.core.ExpressionResolver.ExpressionResolverSupport

  MongoDB Datastore expresion resolution context.
  Since:
    5.2.0

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `MongoResolutionContext<S>` | `childContext()` Create a new `MongoResolutionContext` as child of this context.
    `MongoResolutionContext<S>` | `childContextForUpdate()` Create a new `MongoResolutionContext` as child of this context for update type operations.
    `MongoResolutionContext<S>` | `childContextForUpdate(com.holonplatform.core.Path<?> updatePath)` Create a new `MongoResolutionContext` as child of this context for update type operations.
    `static <S extends com.mongodb.session.ClientSession> MongoResolutionContext<S>` | `create(MongoContext<S> context)` Create a new default `MongoResolutionContext`.
    `static <S extends com.mongodb.session.ClientSession> MongoResolutionContext<S>` | `createForUpdate(MongoContext<S> context)` Create a new default `MongoResolutionContext` for an update type operation.
    `static <S extends com.mongodb.session.ClientSession> MongoResolutionContext<S>` | `createForUpdate(MongoContext<S> context, com.holonplatform.core.Path<?> updatePath)` Create a new default `MongoResolutionContext` for an update type operation, specifying the `Path` to which the update operation refers.
    `default MongoDocumentContext<S>` | `documentContext(com.holonplatform.core.property.PropertySet<?> propertySet)` Create a `MongoDocumentContext` as child of this context.
    `MongoDocumentContext<S>` | `documentContext(com.holonplatform.core.property.PropertySet<?> propertySet, boolean resolveDocumentId)` Create a `MongoDocumentContext` as child of this context.
    `default Optional<String>` | `getAlias(com.holonplatform.core.TypedExpression<?> expression)` Get the alias associated to given expression, if any.
    `default <E> Optional<com.holonplatform.core.TypedExpression<E>>` | `getExpression(String alias)` Get the expression bound to given alias, if any.
    `com.holonplatform.datastore.mongo.core.internal.context.ExpressionAliasProvider` | `getExpressionAliasProvider()` Get the `ExpressionAliasProvider`.
    `default String` | `getNextProjectionFieldName()` For generated projection field names, get the next name.
    `default String` | `getOrCreateAlias(com.holonplatform.core.TypedExpression<?> expression)` Get the alias for given expression or create one if does not exist.
    `Optional<MongoResolutionContext<S>>` | `getParent()` Get the parent context, if available.
    `Optional<QueryOperationType>` | `getQueryOperationType()` Get the `QueryOperationType`.
    `Optional<com.holonplatform.core.Path<?>>` | `getUpdatePath()` If this context is intended for an update type operation, get the optional single `Path` to which the update operation refers.
    `boolean` | `isForUpdate()` Get whether this context is intended for an update type operation.
    `static Optional<MongoResolutionContext<?>>` | `isMongoResolutionContext(com.holonplatform.core.ExpressionResolver.ResolutionContext context)` Checks if given `ExpressionResolver.ResolutionContext` is a `MongoResolutionContext`.
    `default boolean` | `maybeAliasName(String fieldName)` Check if given field name could be an alias name.
    `default <E extends com.holonplatform.core.Expression,R extends com.holonplatform.core.Expression> Optional<R>` | `resolve(E expression, Class<R> resolutionType)` Try to resolve given `expression` using current context resolvers to obtain a `resolutionType` type expression.
    `default <E extends com.holonplatform.core.Expression,R extends com.holonplatform.core.Expression> R` | `resolveOrFail(E expression, Class<R> resolutionType)` Resolve given `expression` using current context resolvers to obtain a `resolutionType` type expression.
    `void` | `setQueryOperationType(QueryOperationType queryOperationType)` Set the `QueryOperationType`.

    - ### Methods inherited from interface com.holonplatform.datastore.mongo.core.context.MongoContext

      `getClientSession, getDatabaseCodecRegistry, getDefaultEnumCodecStrategy, getDefaultReadConcern, getDefaultReadPreference, getDefaultWriteConcern, getDocumentIdResolver, toJson, toJson, toJson, trace, trace, trace, trace`

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

      `resolve`

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

      `getExpressionResolvers`

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

      `addExpressionResolver, addExpressionResolvers, removeExpressionResolver`

- - ### Method Detail

    - #### getParent

          Optional<MongoResolutionContext<S>> getParent()

      Get the parent context, if available.
      Returns:
        Optional parent context

    - #### isForUpdate

          boolean isForUpdate()

      Get whether this context is intended for an update type operation.
      Returns:
        `true` if this context is intended for an update type operation, `false` otherwise

    - #### getUpdatePath

          Optional<com.holonplatform.core.Path<?>> getUpdatePath()

      If this context is intended for an update type operation, get the optional single `Path` to which the update operation refers.
      Returns:
        Optional `Path` to which the update operation refers
      See Also:
        `isForUpdate()`

    - #### getQueryOperationType

          Optional<QueryOperationType> getQueryOperationType()

      Get the `QueryOperationType`.
      Returns:
        Optional query operation type

    - #### setQueryOperationType

          void setQueryOperationType(QueryOperationType queryOperationType)

      Set the `QueryOperationType`.
      Parameters:
        `queryOperationType` - The query operation type to set

    - #### getExpressionAliasProvider

          com.holonplatform.datastore.mongo.core.internal.context.ExpressionAliasProvider getExpressionAliasProvider()

      Get the `ExpressionAliasProvider`.
      Returns:
        Expresion alias provider

    - #### getAlias

          default Optional<String> getAlias(com.holonplatform.core.TypedExpression<?> expression)

      Get the alias associated to given expression, if any.
      Parameters:
        `expression` - The expression to get the alias for (not null)
      Returns:
        Optional expression alias

    - #### getOrCreateAlias

          default String getOrCreateAlias(com.holonplatform.core.TypedExpression<?> expression)

      Get the alias for given expression or create one if does not exist.
      Parameters:
        `expression` - The expression to get the alias for (not null)
      Returns:
        The alias for given expression or a newly created one

    - #### getExpression

          default <E> Optional<com.holonplatform.core.TypedExpression<E>> getExpression(String alias)

      Get the expression bound to given alias, if any.
      Type Parameters:
        `E` - Expression type
      Parameters:
        `alias` - Expression alias
      Returns:
        Optional expression bound to given alias

    - #### getNextProjectionFieldName

          default String getNextProjectionFieldName()

      For generated projection field names, get the next name.
      Returns:
        The next projection field name

    - #### maybeAliasName

          default boolean maybeAliasName(String fieldName)

      Check if given field name could be an alias name.
      Parameters:
        `fieldName` - Field name
      Returns:
        `true` if if given field name could be an alias name, `false` otherwise

    - #### resolve

          default <E extends com.holonplatform.core.Expression,R extends com.holonplatform.core.Expression> Optional<R> resolve(E expression,
                                                                                                                                Class<R> resolutionType)
                                                                                                                         throws com.holonplatform.core.Expression.InvalidExpressionException

      Try to resolve given `expression` using current context resolvers to obtain a `resolutionType` type expression.

      The resolved expression is validate using `Expression.validate()` before returning it to caller.

      Type Parameters:
        `E` - Expression type
        `R` - Resolution type
      Parameters:
        `expression` - Expression to resolve
        `resolutionType` - Expression type to obtain
      Returns:
        Resolved expression
      Throws:
        `com.holonplatform.core.Expression.InvalidExpressionException`

    - #### resolveOrFail

          default <E extends com.holonplatform.core.Expression,R extends com.holonplatform.core.Expression> R resolveOrFail(E expression,
                                                                                                                            Class<R> resolutionType)

      Resolve given `expression` using current context resolvers to obtain a `resolutionType` type expression. If no `ExpressionResolver` is available to resolve given expression, an `Expression.InvalidExpressionException` is thrown.

      The resolved expression is validate using `Expression.validate()` before returning it to caller.

      Type Parameters:
        `E` - Expression type
        `R` - Resolution type
      Parameters:
        `expression` - Expression to resolve
        `resolutionType` - Expression type to obtain
      Returns:
        Resolved expression
      Throws:
        `com.holonplatform.core.Expression.InvalidExpressionException` - If an error occurred during resolution, or if no `ExpressionResolver` is available to resolve given expression or if expression validation failed

    - #### childContext

          MongoResolutionContext<S> childContext()

      Create a new `MongoResolutionContext` as child of this context. This context will be setted as parent of the new context.
      Returns:
        A new `MongoResolutionContext` with this context as parent

    - #### childContextForUpdate

          MongoResolutionContext<S> childContextForUpdate()

      Create a new `MongoResolutionContext` as child of this context for update type operations. This context will be setted as parent of the new context.
      Returns:
        A new `MongoResolutionContext` with this context as parent

    - #### childContextForUpdate

          MongoResolutionContext<S> childContextForUpdate(com.holonplatform.core.Path<?> updatePath)

      Create a new `MongoResolutionContext` as child of this context for update type operations. This context will be setted as parent of the new context.
      Parameters:
        `updatePath` - The path to which the update operation refers
      Returns:
        A new `MongoResolutionContext` with this context as parent

    - #### documentContext

          default MongoDocumentContext<S> documentContext(com.holonplatform.core.property.PropertySet<?> propertySet)

      Create a `MongoDocumentContext` as child of this context.
      Parameters:
        `propertySet` - The `PropertySet` to which the document is bound (not null)
      Returns:
        A new `MongoDocumentContext` instance

    - #### documentContext

          MongoDocumentContext<S> documentContext(com.holonplatform.core.property.PropertySet<?> propertySet,
                                                  boolean resolveDocumentId)

      Create a `MongoDocumentContext` as child of this context.
      Parameters:
        `propertySet` - The `PropertySet` to which the document is bound (not null)
        `resolveDocumentId` - Whether to resolve the document id property
      Returns:
        A new `MongoDocumentContext` instance

    - #### create

          static <S extends com.mongodb.session.ClientSession> MongoResolutionContext<S> create(MongoContext<S> context)

      Create a new default `MongoResolutionContext`.
      Type Parameters:
        `S` - Concrete client session type
      Parameters:
        `context` - MongoContext to use (not null)
      Returns:
        A new `MongoResolutionContext`

    - #### createForUpdate

          static <S extends com.mongodb.session.ClientSession> MongoResolutionContext<S> createForUpdate(MongoContext<S> context)

      Create a new default `MongoResolutionContext` for an update type operation.
      Type Parameters:
        `S` - Concrete client session type
      Parameters:
        `context` - MongoContext to use (not null)
      Returns:
        A new `MongoResolutionContext`

    - #### createForUpdate

          static <S extends com.mongodb.session.ClientSession> MongoResolutionContext<S> createForUpdate(MongoContext<S> context,
                                                                                                         com.holonplatform.core.Path<?> updatePath)

      Create a new default `MongoResolutionContext` for an update type operation, specifying the `Path` to which the update operation refers.
      Type Parameters:
        `S` - Concrete client session type
      Parameters:
        `context` - MongoContext to use (not null)
        `updatePath` - Update operation `Path`
      Returns:
        A new `MongoResolutionContext`

    - #### isMongoResolutionContext

          static Optional<MongoResolutionContext<?>> isMongoResolutionContext(com.holonplatform.core.ExpressionResolver.ResolutionContext context)

      Checks if given `ExpressionResolver.ResolutionContext` is a `MongoResolutionContext`.
      Parameters:
        `context` - The context to check
      Returns:
        if given context is a `MongoResolutionContext`, it is returned as a `MongoResolutionContext` type. Otherwise, an empty Optional is returned.

Copyright © 2019 The Holon Platform. All rights reserved.