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 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 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.DBObject
getOps()
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)boolean
isIsolated()
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.void
setOps(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:UpdateOperations
adds the value to an array field- Specified by:
add
in 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:UpdateOperations
adds the value to an array field- Specified by:
add
in 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:UpdateOperations
adds the values to an array field- Specified by:
addAll
in 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:UpdateOperations
adds the value to an array field if it doesn't already exist in the array- Specified by:
addToSet
in 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:UpdateOperations
adds the values to an array field if they doesn't already exist in the array- Specified by:
addToSet
in 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:UpdateOperations
adds the values to an array field if they doesn't already exist in the array- Specified by:
addToSet
in 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:UpdateOperations
Adds new values to an array field.- Specified by:
push
in 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:UpdateOperations
Adds new values to an array field at the given position- Specified by:
push
in 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:UpdateOperations
Adds new values to an array field.- Specified by:
push
in 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:UpdateOperations
Adds new values to an array field at the given position- Specified by:
push
in 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:UpdateOperations
Decrements the numeric field by 1- Specified by:
dec
in 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:UpdateOperations
Decrements the numeric field by value (must be a positive Double, Float, Long, or Integer).- Specified by:
dec
in interfaceUpdateOperations<T>
- Parameters:
field
- the field to updatevalue
- the value to decrement by- Returns:
- this
-
disableValidation
public UpdateOperations<T> disableValidation()
Description copied from interface:UpdateOperations
Turns off validation (for all calls made after)- Specified by:
disableValidation
in interfaceUpdateOperations<T>
- Returns:
- this
-
enableValidation
public UpdateOperations<T> enableValidation()
Description copied from interface:UpdateOperations
Turns on validation (for all calls made after); by default validation is on- Specified by:
enableValidation
in interfaceUpdateOperations<T>
- Returns:
- this
-
inc
public UpdateOperations<T> inc(java.lang.String field)
Description copied from interface:UpdateOperations
Increments the numeric field by 1- Specified by:
inc
in 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:UpdateOperations
increments the numeric field by value (negatives are allowed)- Specified by:
inc
in interfaceUpdateOperations<T>
- Parameters:
field
- the field to updatevalue
- the value to increment by- Returns:
- this
-
isolated
public UpdateOperations<T> isolated()
Description copied from interface:UpdateOperations
Enables isolation (so this update happens in one shot, without yielding)- Specified by:
isolated
in interfaceUpdateOperations<T>
- 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 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:UpdateOperations
sets the numeric field to value if it is less than the current value.- Specified by:
min
in 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:UpdateOperations
removes the value from the array field- Specified by:
removeAll
in 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:UpdateOperations
removes the values from the array field- Specified by:
removeAll
in 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:UpdateOperations
removes the first value from the array- Specified by:
removeFirst
in interfaceUpdateOperations<T>
- Parameters:
field
- the field to update- Returns:
- this
-
removeLast
public UpdateOperations<T> removeLast(java.lang.String field)
Description copied from interface:UpdateOperations
removes the last value from the array- Specified by:
removeLast
in 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:UpdateOperations
sets the field value- Specified by:
set
in 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:UpdateOperations
sets the field on insert.- Specified by:
setOnInsert
in 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:UpdateOperations
removes the field- Specified by:
unset
in 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:
isIsolated
in 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)
-
-