Class Modify<R>

  • All Implemented Interfaces:
    Updates<Modify<R>>

    public class Modify<R>
    extends java.lang.Object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Updater addToSet​(java.lang.String field, java.lang.Iterable<?> values)
      adds the values to an array field if they doesn't already exist in the array
      Updater addToSet​(java.lang.String field, java.lang.Object value)
      adds the value to an array field if it doesn't already exist in the array
      Updater addToSet​(java.lang.String field, java.util.List<?> values)
      adds the values to an array field if they doesn't already exist in the array
      Updater dec​(java.lang.String field)
      Decrements the numeric field by 1
      Updater dec​(java.lang.String field, java.lang.Number value)
      Decrements the numeric field by value (must be a positive Double, Float, Long, or Integer).
      Updater disableValidation()
      Turns off validation (for all calls made after)
      Updater enableValidation()
      Turns on validation (for all calls made after); by default validation is on
      R execute()  
      R execute​(FindAndModifyOptions options)  
      protected com.mongodb.DBObject getOps()  
      Updater inc​(java.lang.String field)
      Increments the numeric field by 1
      Updater inc​(java.lang.String field, java.lang.Number value)
      increments the numeric field by value (negatives are allowed)
      Updater max​(java.lang.String field, java.lang.Number value)
      Sets the numeric field to value if it is greater than the current value.
      Updater min​(java.lang.String field, java.lang.Number value)
      sets the numeric field to value if it is less than the current value.
      Updater push​(java.lang.String field, java.lang.Object value)
      Adds new values to an array field.
      Updater push​(java.lang.String field, java.lang.Object value, PushOptions options)
      Adds new values to an array field at the given position
      Updater push​(java.lang.String field, java.util.List<?> values)
      Adds new values to an array field.
      Updater push​(java.lang.String field, java.util.List<?> values, PushOptions options)
      Adds new values to an array field at the given position
      protected Updater remove​(java.lang.String fieldExpr, boolean firstNotLast)  
      Updater removeAll​(java.lang.String field, java.lang.Object value)
      removes the value from the array field
      Updater removeAll​(java.lang.String field, java.util.List<?> values)
      removes the values from the array field
      Updater removeFirst​(java.lang.String field)
      removes the first value from the array
      Updater removeLast​(java.lang.String field)
      removes the last value from the array
      Updater set​(java.lang.String field, java.lang.Object value)
      sets the field value
      Updater setOnInsert​(java.lang.String field, java.lang.Object value)
      sets the field on insert.
      protected java.util.List<java.lang.Object> toDBObjList​(MappedField mf, java.util.List<?> values)  
      java.lang.String toString()  
      Updater unset​(java.lang.String field)
      removes the field
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • mapper

        protected final Mapper mapper
      • clazz

        protected final java.lang.Class clazz
    • Method Detail

      • execute

        public R execute()
      • addToSet

        public Updater addToSet​(java.lang.String field,
                                java.lang.Object value)
        Description copied from interface: Updates
        adds the value to an array field if it doesn't already exist in the array
        Specified by:
        addToSet in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        value - the value to add
        Returns:
        this
      • addToSet

        public Updater addToSet​(java.lang.String field,
                                java.util.List<?> values)
        Description copied from interface: Updates
        adds the values to an array field if they doesn't already exist in the array
        Specified by:
        addToSet in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        values - the values to add
        Returns:
        this
      • addToSet

        public Updater addToSet​(java.lang.String field,
                                java.lang.Iterable<?> values)
        Description copied from interface: Updates
        adds the values to an array field if they doesn't already exist in the array
        Specified by:
        addToSet in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        values - the values to add
        Returns:
        this
      • push

        public Updater push​(java.lang.String field,
                            java.lang.Object value)
        Description copied from interface: Updates
        Adds new values to an array field.
        Specified by:
        push in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to updated
        value - the value to add
        Returns:
        this
      • push

        public Updater push​(java.lang.String field,
                            java.lang.Object value,
                            PushOptions options)
        Description copied from interface: Updates
        Adds new values to an array field at the given position
        Specified by:
        push in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to updated
        value - the value to add
        options - the options to apply to the push
        Returns:
        this
      • push

        public Updater push​(java.lang.String field,
                            java.util.List<?> values)
        Description copied from interface: Updates
        Adds new values to an array field.
        Specified by:
        push in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to updated
        values - the values to add
        Returns:
        this
      • push

        public Updater push​(java.lang.String field,
                            java.util.List<?> values,
                            PushOptions options)
        Description copied from interface: Updates
        Adds new values to an array field at the given position
        Specified by:
        push in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to updated
        values - the values to add
        options - the options to apply to the push
        Returns:
        this
      • dec

        public Updater dec​(java.lang.String field)
        Description copied from interface: Updates
        Decrements the numeric field by 1
        Specified by:
        dec in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        Returns:
        this
      • dec

        public Updater dec​(java.lang.String field,
                           java.lang.Number value)
        Description copied from interface: Updates
        Decrements the numeric field by value (must be a positive Double, Float, Long, or Integer).
        Specified by:
        dec in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        value - the value to decrement by
        Returns:
        this
      • disableValidation

        public Updater disableValidation()
        Description copied from interface: Updates
        Turns off validation (for all calls made after)
        Specified by:
        disableValidation in interface Updates<Updater extends Updates>
        Returns:
        this
      • enableValidation

        public Updater enableValidation()
        Description copied from interface: Updates
        Turns on validation (for all calls made after); by default validation is on
        Specified by:
        enableValidation in interface Updates<Updater extends Updates>
        Returns:
        this
      • inc

        public Updater inc​(java.lang.String field)
        Description copied from interface: Updates
        Increments the numeric field by 1
        Specified by:
        inc in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        Returns:
        this
      • inc

        public Updater inc​(java.lang.String field,
                           java.lang.Number value)
        Description copied from interface: Updates
        increments the numeric field by value (negatives are allowed)
        Specified by:
        inc in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        value - the value to increment by
        Returns:
        this
      • max

        public Updater max​(java.lang.String field,
                           java.lang.Number value)
        Description copied from interface: Updates
        Sets the numeric field to value if it is greater than the current value.
        Specified by:
        max in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        value - the value to use
        Returns:
        this
      • min

        public Updater min​(java.lang.String field,
                           java.lang.Number value)
        Description copied from interface: Updates
        sets the numeric field to value if it is less than the current value.
        Specified by:
        min in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        value - the value to use
        Returns:
        this
      • removeAll

        public Updater removeAll​(java.lang.String field,
                                 java.lang.Object value)
        Description copied from interface: Updates
        removes the value from the array field
        Specified by:
        removeAll in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        value - the value to use
        Returns:
        this
      • removeAll

        public Updater removeAll​(java.lang.String field,
                                 java.util.List<?> values)
        Description copied from interface: Updates
        removes the values from the array field
        Specified by:
        removeAll in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        values - the values to use
        Returns:
        this
      • removeFirst

        public Updater removeFirst​(java.lang.String field)
        Description copied from interface: Updates
        removes the first value from the array
        Specified by:
        removeFirst in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        Returns:
        this
      • removeLast

        public Updater removeLast​(java.lang.String field)
        Description copied from interface: Updates
        removes the last value from the array
        Specified by:
        removeLast in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        Returns:
        this
      • set

        public Updater set​(java.lang.String field,
                           java.lang.Object value)
        Description copied from interface: Updates
        sets the field value
        Specified by:
        set in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        value - the value to use
        Returns:
        this
      • setOnInsert

        public Updater setOnInsert​(java.lang.String field,
                                   java.lang.Object value)
        Description copied from interface: Updates
        sets the field on insert.
        Specified by:
        setOnInsert in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        value - the value to use
        Returns:
        this
      • unset

        public Updater unset​(java.lang.String field)
        Description copied from interface: Updates
        removes the field
        Specified by:
        unset in interface Updates<Updater extends Updates>
        Parameters:
        field - the field to update
        Returns:
        this
      • getOps

        protected com.mongodb.DBObject getOps()
        Returns:
        the operations listed
      • remove

        protected Updater remove​(java.lang.String fieldExpr,
                                 boolean firstNotLast)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toDBObjList

        protected java.util.List<java.lang.Object> toDBObjList​(MappedField mf,
                                                               java.util.List<?> values)