Class UpdateBuilder

java.lang.Object
dev.getelements.elements.dao.mongo.UpdateBuilder

public class UpdateBuilder extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an empty UpdateBuilder.
    UpdateBuilder(Collection<dev.morphia.query.updates.UpdateOperator> updates)
    Constructs an UpdateBuilder with the supplied updates.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.mongodb.client.result.UpdateResult
    execute(dev.morphia.query.Query<?> query, dev.morphia.UpdateOptions options)
    Equivalent to invoking update(Query) (Query)}.Update.execute(UpdateOptions)
    <ModelT> ModelT
    execute(dev.morphia.query.Query<ModelT> query, dev.morphia.ModifyOptions options)
    Equivalent to invoking modify(Query).
    <ModelT> dev.morphia.query.Modify<ModelT>
    modify(dev.morphia.query.Query<ModelT> query)
    Builds the Modify from the supplied Query.
    Builds a new UpdateBuilder based on this instance.
    <ModelT> dev.morphia.query.Update<ModelT>
    update(dev.morphia.query.Query<ModelT> query)
    Deprecated.
    depends on deprecated code and is slated for removal
    with(dev.morphia.query.updates.UpdateOperator op)
    Appends an UpdateOperator.
    with(dev.morphia.query.updates.UpdateOperator first, dev.morphia.query.updates.UpdateOperator... subsequent)
    Appends an UpdateOperator.
    <T> T
    Accepts an Function which consumes this UpdateBuilder and returns the value returned by the function.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UpdateBuilder

      public UpdateBuilder()
      Constructs an empty UpdateBuilder.
    • UpdateBuilder

      public UpdateBuilder(Collection<dev.morphia.query.updates.UpdateOperator> updates)
      Constructs an UpdateBuilder with the supplied updates.
      Parameters:
      updates - the updates to apply
  • Method Details

    • with

      public UpdateBuilder with(dev.morphia.query.updates.UpdateOperator op)
      Appends an UpdateOperator.
      Parameters:
      op - the operator
      Returns:
      this instance
    • with

      public UpdateBuilder with(dev.morphia.query.updates.UpdateOperator first, dev.morphia.query.updates.UpdateOperator... subsequent)
      Appends an UpdateOperator.
      Parameters:
      first - the first operator to apply
      subsequent - the subsequent operators to apply
      Returns:
      this instance
    • with

      public <T> T with(Function<UpdateBuilder,T> op)
      Accepts an Function which consumes this UpdateBuilder and returns the value returned by the function.
      Type Parameters:
      T - the return type.
      Parameters:
      op - the operation to apply to this UpdateBuilder
      Returns:
      the value returned from the operation
    • modify

      public <ModelT> dev.morphia.query.Modify<ModelT> modify(dev.morphia.query.Query<ModelT> query)
      Builds the Modify from the supplied Query.
      Type Parameters:
      ModelT - the model type to update
      Parameters:
      query - the Query
      Returns:
      an instance of Modify with the updates supplied by this builder
      Throws:
      IllegalStateException - if no updates were applied.
    • update

      public <ModelT> dev.morphia.query.Update<ModelT> update(dev.morphia.query.Query<ModelT> query)
      Deprecated.
      depends on deprecated code and is slated for removal
      Builds the Update from the supplied Query.
      Type Parameters:
      ModelT - the model type to update
      Parameters:
      query - the Query
      Returns:
      an instance of Update with the updates supplied by this builder
      Throws:
      IllegalStateException - if no updates were applied.
    • then

      public UpdateBuilder then()
      Builds a new UpdateBuilder based on this instance.
      Returns:
      a new UpdateBuilder instanc
    • execute

      public com.mongodb.client.result.UpdateResult execute(dev.morphia.query.Query<?> query, dev.morphia.UpdateOptions options)
      Equivalent to invoking update(Query) (Query)}.Update.execute(UpdateOptions)
      Parameters:
      query - the Query against which to apply the updates
      Returns:
      the UpdateResult
    • execute

      public <ModelT> ModelT execute(dev.morphia.query.Query<ModelT> query, dev.morphia.ModifyOptions options)
      Equivalent to invoking modify(Query). Modify.execute(ModifyOptions)
      Parameters:
      query - the Query against which to apply the updates
      Returns:
      the model