Class UpdateOp
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.document.UpdateOp
-
public final class UpdateOp extends Object
A DocumentStore "update" operation for one document.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UpdateOp.Condition
A condition to check before an update is applied.static class
UpdateOp.Key
A key for an operation consists of a property name and an optional revision.static class
UpdateOp.Operation
A DocumentStore operation for a given key within a document.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UpdateOp
copy()
Creates a deep copy of this update operation.Map<UpdateOp.Key,UpdateOp.Operation>
getChanges()
Map<UpdateOp.Key,UpdateOp.Condition>
getConditions()
@NotNull String
getId()
UpdateOp
getReverseOperation()
boolean
hasChanges()
Checks if the UpdateOp has any change operation is registered with current update operationvoid
increment(@NotNull String property, long value)
Increment the value.boolean
isNew()
void
remove(@NotNull String property)
Remove a property.void
removeMapEntry(@NotNull String property, @NotNull Revision revision)
Remove a map entry.void
set(String property, boolean value)
Set the property to the given boolean value.void
set(String property, long value)
Set the property to the given long value.void
set(String property, String value)
Set the property to the given String value.void
setNew(boolean isNew)
UpdateOp
shallowCopy(String id)
Creates an update operation for the document with the given id.String
toString()
-
-
-
Constructor Detail
-
UpdateOp
public UpdateOp(@NotNull @NotNull String id, boolean isNew)
Create an update operation for the document with the given id. The commit root is assumed to be the path, unless this is changed later on.- Parameters:
id
- the primary keyisNew
- whether this is a new document
-
-
Method Detail
-
shallowCopy
public UpdateOp shallowCopy(String id)
Creates an update operation for the document with the given id. The changes are shared with the this update operation.- Parameters:
id
- the primary key.
-
copy
public UpdateOp copy()
Creates a deep copy of this update operation. Changes to the returnedUpdateOp
do not affect this object.- Returns:
- a copy of this operation.
-
getId
@NotNull public @NotNull String getId()
-
isNew
public boolean isNew()
-
setNew
public void setNew(boolean isNew)
-
getChanges
public Map<UpdateOp.Key,UpdateOp.Operation> getChanges()
-
getConditions
public Map<UpdateOp.Key,UpdateOp.Condition> getConditions()
-
hasChanges
public boolean hasChanges()
Checks if the UpdateOp has any change operation is registered with current update operation- Returns:
- true if any change operation is created
-
remove
public void remove(@NotNull @NotNull String property)
Remove a property.- Parameters:
property
- the property name
-
removeMapEntry
public void removeMapEntry(@NotNull @NotNull String property, @NotNull @NotNull Revision revision)
Remove a map entry. The property is a map of revisions / values.- Parameters:
property
- the propertyrevision
- the revision
-
set
public void set(String property, long value)
Set the property to the given long value.- Parameters:
property
- the property namevalue
- the value
-
set
public void set(String property, boolean value)
Set the property to the given boolean value.- Parameters:
property
- the property namevalue
- the value
-
set
public void set(String property, String value)
Set the property to the given String value.Note that
Document.ID
must not be set using this method; it is sufficiently specified by the id parameter set in the constructor.- Parameters:
property
- the property namevalue
- the value- Throws:
IllegalArgumentException
- if an attempt is made to setDocument.ID
.
-
increment
public void increment(@NotNull @NotNull String property, long value)
Increment the value.- Parameters:
property
- the keyvalue
- the increment
-
getReverseOperation
public UpdateOp getReverseOperation()
-
-