Class AssignFieldPathUpdate


  • public class AssignFieldPathUpdate
    extends FieldPathUpdate
    Author:
    Thomas Gundersen
    • Constructor Detail

      • AssignFieldPathUpdate

        public AssignFieldPathUpdate​(DocumentType type,
                                     java.lang.String fieldPath,
                                     java.lang.String whereClause,
                                     FieldValue newValue)
        Creates an assignment update that overwrites the old value with the given new value.
        Parameters:
        type - The document type the assignment works on.
        fieldPath - The field path of the field to be overwritten.
        whereClause - A document selection string that selects documents and variables to be updated.
        newValue - The new value of the assignment.
      • AssignFieldPathUpdate

        public AssignFieldPathUpdate​(DocumentType type,
                                     java.lang.String fieldPath,
                                     FieldValue newValue)
      • AssignFieldPathUpdate

        public AssignFieldPathUpdate​(DocumentType type,
                                     java.lang.String fieldPath,
                                     java.lang.String whereClause,
                                     java.lang.String expression)
        Creates an assign statement based on a mathematical expression.
        Parameters:
        type - The document type the assignment works on.
        fieldPath - The field path of the field to be overwritten.
        whereClause - A document selection string that selects documents and variables to be updated.
        expression - The mathematical expression to apply. Use $value to signify the previous value of the field.
      • AssignFieldPathUpdate

        public AssignFieldPathUpdate​(DocumentType type,
                                     DocumentUpdateReader reader)
        Creates an assign update from a serialized object.
        Parameters:
        type - The document type the assignment will work on.
        reader - A reader that can deserialize something into this object.
      • AssignFieldPathUpdate

        public AssignFieldPathUpdate​(DocumentType type,
                                     java.lang.String fieldPath)
    • Method Detail

      • setNewValue

        public void setNewValue​(FieldValue value)
        Turns this assignment into a literal one.
        Parameters:
        value - The new value to assign to the document.
      • getNewValue

        public FieldValue getNewValue()
        Returns:
        Returns the value to assign, or null if this is a mathematical expression.
      • setExpression

        public void setExpression​(java.lang.String value)
        Turns this assignment into a mathematical expression assignment.
        Parameters:
        value - The expression to use for assignment.
      • getExpression

        public java.lang.String getExpression()
        Returns:
        Returns the arithmetic expression to assign, or null if this is not a mathematical expression.
      • setRemoveIfZero

        public void setRemoveIfZero​(boolean removeIfZero)
        If set to true, and the new value assigned evaluates to a numeric value of 0, removes the value instead of setting it. Default is false.
      • setCreateMissingPath

        public void setCreateMissingPath​(boolean createMissingPath)
        If set to true, and any part of the field path specified does not exist (except for array indexes), we create the path as necessary. Default is true.
      • isArithmetic

        public boolean isArithmetic()
        Returns:
        Returns true if this assignment is an arithmetic operation.
      • getCreateMissingPath

        public boolean getCreateMissingPath()
      • getRemoveIfZero

        public boolean getRemoveIfZero()
      • getFieldValue

        public FieldValue getFieldValue()