Class UpdateExpressionConverter

java.lang.Object
software.amazon.awssdk.enhanced.dynamodb.internal.update.UpdateExpressionConverter

public final class UpdateExpressionConverter extends Object
In order to convert it to the format that DynamoDB accepts, the toExpression() method will create an Expression with a coalesced string representation of its actions, and the ExpressionNames and ExpressionValues maps associated with all present actions. Note: Once an Expression has been obtained, you cannot combine it with another update Expression since they can't be reliably combined using a token. Validation When an UpdateExpression is created or merged with another, the code validates the integrity of the expression to ensure a successful database update. - The same attribute MAY NOT be chosen for updates in more than one action expression. This is checked by verifying that attribute only has one representation in the AttributeNames map. - The same attribute MAY NOT have more than one value. This is checked by verifying that attribute only has one representation in the AttributeValues map.
  • Method Details

    • toExpression

      public static Expression toExpression(UpdateExpression expression)
      Returns an Expression where all update actions in the UpdateExpression have been concatenated according to the rules of DDB Update Expressions, and all expression names and values have been combined into single maps, respectively. Observe that the resulting expression string should never be joined with another expression string, independently of whether it represents an update expression, conditional expression or another type of expression, since once the string is generated that update expression is the final format accepted by DDB.
      Returns:
      an Expression representing the concatenation of all actions in this UpdateExpression
    • findAttributeNames

      public static List<String> findAttributeNames(UpdateExpression updateExpression)
      Attempts to find the list of attribute names that will be updated for the supplied UpdateExpression by looking at the combined collection of paths and ExpressionName values. Because attribute names can be composed from nested attribute references and list references, the leftmost part will be returned if composition is detected.

      Examples: The expression contains a DeleteAction with a path value of 'MyAttribute[1]'; the list returned will have 'MyAttribute' as an element.}

      Returns:
      A list of top level attribute names that have update actions associated.