Class AssignFieldPathUpdate

java.lang.Object
com.yahoo.document.fieldpathupdate.FieldPathUpdate
com.yahoo.document.fieldpathupdate.AssignFieldPathUpdate

public class AssignFieldPathUpdate extends FieldPathUpdate
Author:
Thomas Gundersen
  • Field Details

  • Constructor Details

    • AssignFieldPathUpdate

      public AssignFieldPathUpdate(DocumentType type, String fieldPath, 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, String fieldPath, FieldValue newValue)
    • AssignFieldPathUpdate

      public AssignFieldPathUpdate(DocumentType type, String fieldPath, String whereClause, 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, String fieldPath)
  • Method Details

    • 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(String value)
      Turns this assignment into a mathematical expression assignment.
      Parameters:
      value - The expression to use for assignment.
    • getExpression

      public 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.
    • serialize

      public void serialize(VespaDocumentSerializer6 data)
      Overrides:
      serialize in class FieldPathUpdate
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class FieldPathUpdate
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class FieldPathUpdate
    • toString

      public String toString()
      Overrides:
      toString in class FieldPathUpdate
    • getCreateMissingPath

      public boolean getCreateMissingPath()
    • getRemoveIfZero

      public boolean getRemoveIfZero()
    • getFieldValue

      public FieldValue getFieldValue()