Class UpdateOpsImpl<T>

  • Type Parameters:
    T - the type to update
    All Implemented Interfaces:
    UpdateOperations<T>

    public class UpdateOpsImpl<T>
    extends java.lang.Object
    implements UpdateOperations<T>
    Author:
    Scott Hernandez
    • Constructor Summary

      Constructors 
      Constructor Description
      UpdateOpsImpl​(java.lang.Class<T> type, Mapper mapper)
      Creates an UpdateOpsImpl for the type given.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected void add​(UpdateOperator op, java.lang.String f, java.lang.Object value, boolean convert)  
      UpdateOperations<T> add​(java.lang.String field, java.lang.Object value)
      Deprecated.
      UpdateOperations<T> add​(java.lang.String field, java.lang.Object value, boolean addDups)
      Deprecated.
      UpdateOperations<T> addAll​(java.lang.String field, java.util.List<?> values, boolean addDups)
      Deprecated.
      UpdateOperations<T> 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
      UpdateOperations<T> 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
      UpdateOperations<T> 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
      UpdateOperations<T> dec​(java.lang.String field)
      Decrements the numeric field by 1
      UpdateOperations<T> dec​(java.lang.String field, java.lang.Number value)
      Decrements the numeric field by value (must be a positive Double, Float, Long, or Integer).
      UpdateOperations<T> disableValidation()
      Turns off validation (for all calls made after)
      UpdateOperations<T> enableValidation()
      Turns on validation (for all calls made after); by default validation is on
      com.mongodb.DBObject getOps()  
      UpdateOperations<T> inc​(java.lang.String field)
      Increments the numeric field by 1
      UpdateOperations<T> inc​(java.lang.String field, java.lang.Number value)
      increments the numeric field by value (negatives are allowed)
      UpdateOperations<T> max​(java.lang.String field, java.lang.Number value)
      Sets the numeric field to value if it is greater than the current value.
      UpdateOperations<T> min​(java.lang.String field, java.lang.Number value)
      sets the numeric field to value if it is less than the current value.
      UpdateOperations<T> push​(java.lang.String field, java.lang.Object value)
      Adds new values to an array field.
      UpdateOperations<T> push​(java.lang.String field, java.lang.Object value, PushOptions options)
      Adds new values to an array field at the given position
      UpdateOperations<T> push​(java.lang.String field, java.util.List<?> values)
      Adds new values to an array field.
      UpdateOperations<T> push​(java.lang.String field, java.util.List<?> values, PushOptions options)
      Adds new values to an array field at the given position
      protected UpdateOperations<T> remove​(java.lang.String fieldExpr, boolean firstNotLast)  
      UpdateOperations<T> removeAll​(java.lang.String field, java.lang.Object value)
      removes the value from the array field
      UpdateOperations<T> removeAll​(java.lang.String field, java.util.List<?> values)
      removes the values from the array field
      UpdateOperations<T> removeFirst​(java.lang.String field)
      removes the first value from the array
      UpdateOperations<T> removeLast​(java.lang.String field)
      removes the last value from the array
      UpdateOperations<T> set​(java.lang.String field, java.lang.Object value)
      sets the field value
      UpdateOperations<T> setOnInsert​(java.lang.String field, java.lang.Object value)
      sets the field on insert.
      void setOps​(com.mongodb.DBObject ops)
      Sets the operations for this UpdateOpsImpl
      protected java.util.List<java.lang.Object> toDBObjList​(MappedField mf, java.util.List<?> values)  
      UpdateOperations<T> unset​(java.lang.String field)
      removes the field
      • Methods inherited from class java.lang.Object

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

      • UpdateOpsImpl

        public UpdateOpsImpl​(java.lang.Class<T> type,
                             Mapper mapper)
        Creates an UpdateOpsImpl for the type given.
        Parameters:
        type - the type to update
        mapper - the Mapper to use
    • Method Detail

      • add

        @Deprecated
        public UpdateOperations<T> add​(java.lang.String field,
                                       java.lang.Object value)
        Deprecated.
        Description copied from interface: UpdateOperations
        adds the value to an array field
        Specified by:
        add in interface UpdateOperations<T>
        Parameters:
        field - the field to update
        value - the value to add
        Returns:
        this
      • add

        @Deprecated
        public UpdateOperations<T> add​(java.lang.String field,
                                       java.lang.Object value,
                                       boolean addDups)
        Deprecated.
        Description copied from interface: UpdateOperations
        adds the value to an array field
        Specified by:
        add in interface UpdateOperations<T>
        Parameters:
        field - the field to update
        value - the value to add
        addDups - if true, the value will be added even if it already exists in the array ($push)
        Returns:
        this
      • addAll

        @Deprecated
        public UpdateOperations<T> addAll​(java.lang.String field,
                                          java.util.List<?> values,
                                          boolean addDups)
        Deprecated.
        Description copied from interface: UpdateOperations
        adds the values to an array field
        Specified by:
        addAll in interface UpdateOperations<T>
        Parameters:
        field - the field to update
        values - the values to add
        addDups - if true, the values will be added even if they already exists in the array ($push)
        Returns:
        this
      • addToSet

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        public com.mongodb.DBObject getOps()
        Returns:
        the operations listed
      • setOps

        public void setOps​(com.mongodb.DBObject ops)
        Sets the operations for this UpdateOpsImpl
        Parameters:
        ops - the operations
      • add

        protected void add​(UpdateOperator op,
                           java.lang.String f,
                           java.lang.Object value,
                           boolean convert)
      • remove

        protected UpdateOperations<T> remove​(java.lang.String fieldExpr,
                                             boolean firstNotLast)
      • toDBObjList

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