Package dev.morphia.query
Class UpdateOpsImpl<T>
- java.lang.Object
-
- dev.morphia.query.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 voidadd(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 arrayUpdateOperations<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 arrayUpdateOperations<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 arrayUpdateOperations<T>dec(java.lang.String field)Decrements the numeric field by 1UpdateOperations<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 oncom.mongodb.DBObjectgetOps()UpdateOperations<T>inc(java.lang.String field)Increments the numeric field by 1UpdateOperations<T>inc(java.lang.String field, java.lang.Number value)increments the numeric field by value (negatives are allowed)booleanisIsolated()UpdateOperations<T>isolated()Enables isolation (so this update happens in one shot, without yielding)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 positionUpdateOperations<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 positionprotected 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 fieldUpdateOperations<T>removeAll(java.lang.String field, java.util.List<?> values)removes the values from the array fieldUpdateOperations<T>removeFirst(java.lang.String field)removes the first value from the arrayUpdateOperations<T>removeLast(java.lang.String field)removes the last value from the arrayUpdateOperations<T>set(java.lang.String field, java.lang.Object value)sets the field valueUpdateOperations<T>setOnInsert(java.lang.String field, java.lang.Object value)sets the field on insert.voidsetOps(com.mongodb.DBObject ops)Sets the operations for this UpdateOpsImplprotected java.util.List<java.lang.Object>toDBObjList(MappedField mf, java.util.List<?> values)UpdateOperations<T>unset(java.lang.String field)removes the field
-
-
-
Method Detail
-
add
@Deprecated public UpdateOperations<T> add(java.lang.String field, java.lang.Object value)
Deprecated.Description copied from interface:UpdateOperationsadds the value to an array field- Specified by:
addin interfaceUpdateOperations<T>- Parameters:
field- the field to updatevalue- 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:UpdateOperationsadds the value to an array field- Specified by:
addin interfaceUpdateOperations<T>- Parameters:
field- the field to updatevalue- the value to addaddDups- 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:UpdateOperationsadds the values to an array field- Specified by:
addAllin interfaceUpdateOperations<T>- Parameters:
field- the field to updatevalues- the values to addaddDups- 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:UpdateOperationsadds the value to an array field if it doesn't already exist in the array- Specified by:
addToSetin interfaceUpdateOperations<T>- Parameters:
field- the field to updatevalue- the value to add- Returns:
- this
-
addToSet
public UpdateOperations<T> addToSet(java.lang.String field, java.util.List<?> values)
Description copied from interface:UpdateOperationsadds the values to an array field if they doesn't already exist in the array- Specified by:
addToSetin interfaceUpdateOperations<T>- Parameters:
field- the field to updatevalues- the values to add- Returns:
- this
-
addToSet
public UpdateOperations<T> addToSet(java.lang.String field, java.lang.Iterable<?> values)
Description copied from interface:UpdateOperationsadds the values to an array field if they doesn't already exist in the array- Specified by:
addToSetin interfaceUpdateOperations<T>- Parameters:
field- the field to updatevalues- the values to add- Returns:
- this
-
push
public UpdateOperations<T> push(java.lang.String field, java.lang.Object value)
Description copied from interface:UpdateOperationsAdds new values to an array field.- Specified by:
pushin interfaceUpdateOperations<T>- Parameters:
field- the field to updatedvalue- 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:UpdateOperationsAdds new values to an array field at the given position- Specified by:
pushin interfaceUpdateOperations<T>- Parameters:
field- the field to updatedvalue- the value to addoptions- 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:UpdateOperationsAdds new values to an array field.- Specified by:
pushin interfaceUpdateOperations<T>- Parameters:
field- the field to updatedvalues- 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:UpdateOperationsAdds new values to an array field at the given position- Specified by:
pushin interfaceUpdateOperations<T>- Parameters:
field- the field to updatedvalues- the values to addoptions- the options to apply to the push- Returns:
- this
-
dec
public UpdateOperations<T> dec(java.lang.String field)
Description copied from interface:UpdateOperationsDecrements the numeric field by 1- Specified by:
decin interfaceUpdateOperations<T>- Parameters:
field- the field to update- Returns:
- this
-
dec
public UpdateOperations<T> dec(java.lang.String field, java.lang.Number value)
Description copied from interface:UpdateOperationsDecrements the numeric field by value (must be a positive Double, Float, Long, or Integer).- Specified by:
decin interfaceUpdateOperations<T>- Parameters:
field- the field to updatevalue- the value to decrement by- Returns:
- this
-
disableValidation
public UpdateOperations<T> disableValidation()
Description copied from interface:UpdateOperationsTurns off validation (for all calls made after)- Specified by:
disableValidationin interfaceUpdateOperations<T>- Returns:
- this
-
enableValidation
public UpdateOperations<T> enableValidation()
Description copied from interface:UpdateOperationsTurns on validation (for all calls made after); by default validation is on- Specified by:
enableValidationin interfaceUpdateOperations<T>- Returns:
- this
-
inc
public UpdateOperations<T> inc(java.lang.String field)
Description copied from interface:UpdateOperationsIncrements the numeric field by 1- Specified by:
incin interfaceUpdateOperations<T>- Parameters:
field- the field to update- Returns:
- this
-
inc
public UpdateOperations<T> inc(java.lang.String field, java.lang.Number value)
Description copied from interface:UpdateOperationsincrements the numeric field by value (negatives are allowed)- Specified by:
incin interfaceUpdateOperations<T>- Parameters:
field- the field to updatevalue- the value to increment by- Returns:
- this
-
isolated
public UpdateOperations<T> isolated()
Description copied from interface:UpdateOperationsEnables isolation (so this update happens in one shot, without yielding)- Specified by:
isolatedin interfaceUpdateOperations<T>- Returns:
- this
-
max
public UpdateOperations<T> max(java.lang.String field, java.lang.Number value)
Description copied from interface:UpdateOperationsSets the numeric field to value if it is greater than the current value.- Specified by:
maxin interfaceUpdateOperations<T>- Parameters:
field- the field to updatevalue- the value to use- Returns:
- this
-
min
public UpdateOperations<T> min(java.lang.String field, java.lang.Number value)
Description copied from interface:UpdateOperationssets the numeric field to value if it is less than the current value.- Specified by:
minin interfaceUpdateOperations<T>- Parameters:
field- the field to updatevalue- the value to use- Returns:
- this
-
removeAll
public UpdateOperations<T> removeAll(java.lang.String field, java.lang.Object value)
Description copied from interface:UpdateOperationsremoves the value from the array field- Specified by:
removeAllin interfaceUpdateOperations<T>- Parameters:
field- the field to updatevalue- the value to use- Returns:
- this
-
removeAll
public UpdateOperations<T> removeAll(java.lang.String field, java.util.List<?> values)
Description copied from interface:UpdateOperationsremoves the values from the array field- Specified by:
removeAllin interfaceUpdateOperations<T>- Parameters:
field- the field to updatevalues- the values to use- Returns:
- this
-
removeFirst
public UpdateOperations<T> removeFirst(java.lang.String field)
Description copied from interface:UpdateOperationsremoves the first value from the array- Specified by:
removeFirstin interfaceUpdateOperations<T>- Parameters:
field- the field to update- Returns:
- this
-
removeLast
public UpdateOperations<T> removeLast(java.lang.String field)
Description copied from interface:UpdateOperationsremoves the last value from the array- Specified by:
removeLastin interfaceUpdateOperations<T>- Parameters:
field- the field to update- Returns:
- this
-
set
public UpdateOperations<T> set(java.lang.String field, java.lang.Object value)
Description copied from interface:UpdateOperationssets the field value- Specified by:
setin interfaceUpdateOperations<T>- Parameters:
field- the field to updatevalue- the value to use- Returns:
- this
-
setOnInsert
public UpdateOperations<T> setOnInsert(java.lang.String field, java.lang.Object value)
Description copied from interface:UpdateOperationssets the field on insert.- Specified by:
setOnInsertin interfaceUpdateOperations<T>- Parameters:
field- the field to updatevalue- the value to use- Returns:
- this
-
unset
public UpdateOperations<T> unset(java.lang.String field)
Description copied from interface:UpdateOperationsremoves the field- Specified by:
unsetin interfaceUpdateOperations<T>- Parameters:
field- the field to update- 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
-
isIsolated
public boolean isIsolated()
- Specified by:
isIsolatedin interfaceUpdateOperations<T>- Returns:
- true if isolated
-
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)
-
-