Class BindableMongoExpression

java.lang.Object
org.springframework.data.mongodb.BindableMongoExpression
All Implemented Interfaces:
MongoExpression

public class BindableMongoExpression extends Object implements MongoExpression
A MongoExpression using the ParameterBindingDocumentCodec for parsing a raw (json) expression. The expression will be wrapped within { ... } if necessary. The actual parsing and parameter binding of placeholders like ?0 is delayed upon first call on the the target Document via toDocument().
 $toUpper : $name                -> { '$toUpper' : '$name' }

 { '$toUpper' : '$name' }        -> { '$toUpper' : '$name' }

 { '$toUpper' : '?0' }, "$name"  -> { '$toUpper' : '$name' }
 
Some types might require a special Codec. If so, make sure to provide a CodecRegistry containing the required codec via withCodecRegistry(CodecRegistry).
Since:
3.2
Author:
Christoph Strobl
  • Constructor Details

    • BindableMongoExpression

      public BindableMongoExpression(String expression, @Nullable Object[] args)
      Create a new instance of BindableMongoExpression.
      Parameters:
      expression - must not be null.
      args - can be null.
    • BindableMongoExpression

      public BindableMongoExpression(String expression, @Nullable CodecRegistryProvider codecRegistryProvider, @Nullable Object[] args)
      Create a new instance of BindableMongoExpression.
      Parameters:
      expression - must not be null.
      codecRegistryProvider - can be null.
      args - can be null.
  • Method Details

    • withCodecRegistry

      public BindableMongoExpression withCodecRegistry(org.bson.codecs.configuration.CodecRegistry codecRegistry)
      Provide the CodecRegistry used to convert expressions.
      Parameters:
      codecRegistry - must not be null.
      Returns:
      new instance of BindableMongoExpression.
    • bind

      public BindableMongoExpression bind(Object... args)
      Provide the arguments to bind to the placeholders via their index.
      Parameters:
      args - must not be null.
      Returns:
      new instance of BindableMongoExpression.
    • toDocument

      public org.bson.Document toDocument()
      Description copied from interface: MongoExpression
      Obtain the native Document representation.
      Specified by:
      toDocument in interface MongoExpression
      Returns:
      never null.
    • toString

      public String toString()
      Overrides:
      toString in class Object