Class UpdateBase<T,​Updater extends Updates>

  • Type Parameters:
    T -
    Updater -
    All Implemented Interfaces:
    Updates<Updater>
    Direct Known Subclasses:
    Modify, Update

    public abstract class UpdateBase<T,​Updater extends Updates>
    extends Object
    implements Updates<Updater>
    Developer note.
    This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
    • Method Detail

      • getType

        protected Class<T> getType()
      • addToSet

        public Updater addToSet​(String field,
                                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<T>
        Parameters:
        field - the field to update
        value - the value to add
        Returns:
        this
      • addToSet

        public Updater addToSet​(String field,
                                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<T>
        Parameters:
        field - the field to update
        values - the values to add
        Returns:
        this
      • addToSet

        public Updater addToSet​(String field,
                                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<T>
        Parameters:
        field - the field to update
        values - the values to add
        Returns:
        this
      • dec

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

        public Updater dec​(String field,
                           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<T>
        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<T>
        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<T>
        Returns:
        this
      • inc

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

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

        public Updater max​(String field,
                           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<T>
        Parameters:
        field - the field to update
        value - the value to use
        Returns:
        this
      • min

        public Updater min​(String field,
                           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<T>
        Parameters:
        field - the field to update
        value - the value to use
        Returns:
        this
      • pull

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

        public Updater pullAll​(String field,
                               List<?> values)
        Description copied from interface: Updates
        removes the values from the array field
        Specified by:
        pullAll in interface Updates<T>
        Parameters:
        field - the field to update
        values - the values to use
        Returns:
        this
      • push

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

        public Updater push​(String field,
                            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<T>
        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​(String field,
                            List<?> values)
        Description copied from interface: Updates
        Adds new values to an array field.
        Specified by:
        push in interface Updates<T>
        Parameters:
        field - the field to updated
        values - the values to add
        Returns:
        this
      • push

        public Updater push​(String field,
                            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<T>
        Parameters:
        field - the field to updated
        values - the values to add
        options - the options to apply to the push
        Returns:
        this
      • removeAll

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

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

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

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

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

        public Updater set​(Object entity)
        Description copied from interface: Updates
        sets the entity value to completely replace the stored document
        Specified by:
        set in interface Updates<T>
        Parameters:
        entity - the entity to store
        Returns:
        this
      • setOnInsert

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

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

        protected Updater remove​(String fieldExpr,
                                 boolean firstNotLast)
      • toDocument

        public org.bson.Document toDocument()
        Returns:
        the operations listed