Class UpdateOp


  • public final class UpdateOp
    extends java.lang.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.
    • Constructor Summary

      Constructors 
      Constructor Description
      UpdateOp​(@NotNull java.lang.String id, boolean isNew)
      Create an update operation for the document with the given id.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      UpdateOp copy()
      Creates a deep copy of this update operation.
      java.util.Map<UpdateOp.Key,​UpdateOp.Operation> getChanges()  
      java.util.Map<UpdateOp.Key,​UpdateOp.Condition> getConditions()  
      @NotNull java.lang.String getId()  
      UpdateOp getReverseOperation()  
      boolean hasChanges()
      Checks if the UpdateOp has any change operation is registered with current update operation
      void increment​(@NotNull java.lang.String property, long value)
      Increment the value.
      boolean isNew()  
      void remove​(@NotNull java.lang.String property)
      Remove a property.
      void removeMapEntry​(@NotNull java.lang.String property, @NotNull Revision revision)
      Remove a map entry.
      void set​(java.lang.String property, boolean value)
      Set the property to the given boolean value.
      void set​(java.lang.String property, long value)
      Set the property to the given long value.
      void set​(java.lang.String property, java.lang.String value)
      Set the property to the given String value.
      void setNew​(boolean isNew)  
      UpdateOp shallowCopy​(java.lang.String id)
      Creates an update operation for the document with the given id.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • UpdateOp

        public UpdateOp​(@NotNull
                        @NotNull java.lang.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 key
        isNew - whether this is a new document
    • Method Detail

      • shallowCopy

        public UpdateOp shallowCopy​(java.lang.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 returned UpdateOp do not affect this object.
        Returns:
        a copy of this operation.
      • getId

        @NotNull
        public @NotNull java.lang.String getId()
      • isNew

        public boolean isNew()
      • setNew

        public void setNew​(boolean isNew)
      • 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 java.lang.String property)
        Remove a property.
        Parameters:
        property - the property name
      • removeMapEntry

        public void removeMapEntry​(@NotNull
                                   @NotNull java.lang.String property,
                                   @NotNull
                                   @NotNull Revision revision)
        Remove a map entry. The property is a map of revisions / values.
        Parameters:
        property - the property
        revision - the revision
      • set

        public void set​(java.lang.String property,
                        long value)
        Set the property to the given long value.
        Parameters:
        property - the property name
        value - the value
      • set

        public void set​(java.lang.String property,
                        boolean value)
        Set the property to the given boolean value.
        Parameters:
        property - the property name
        value - the value
      • set

        public void set​(java.lang.String property,
                        java.lang.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 name
        value - the value
        Throws:
        java.lang.IllegalArgumentException - if an attempt is made to set Document.ID.
      • increment

        public void increment​(@NotNull
                              @NotNull java.lang.String property,
                              long value)
        Increment the value.
        Parameters:
        property - the key
        value - the increment
      • getReverseOperation

        public UpdateOp getReverseOperation()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object