/* * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.amazonaws.services.dynamodbv2.model; import java.io.Serializable; /** *

* For the UpdateItem operation, represents the attributes to be * modified, the action to perform on each, and the new value for each. *

* *

* You cannot use UpdateItem to update any primary key attributes. * Instead, you will need to delete the item, and then use PutItem * to create a new item with new attributes. *

*
*

* Attribute values cannot be null; string and binary type attributes must have * lengths greater than zero; and set type attributes must not be empty. * Requests with empty values will be rejected with a * ValidationException exception. *

*/ public class AttributeValueUpdate implements Serializable { /** *

* Represents the data for an attribute. *

*

* Each attribute value is described as a name-value pair. The name is the * data type, and the value is the data itself. *

*

* For more information, see Data Types in the Amazon DynamoDB Developer Guide. *

*/ private AttributeValue value; /** *

* Specifies how to perform the update. Valid values are PUT * (default), DELETE, and ADD. The behavior * depends on whether the specified primary key already exists in the table. *

*

* If an item with the specified Key is found in the table: *

* *

* If no item with the specified Key is found: *

* *

* Constraints:
* Allowed Values: ADD, PUT, DELETE */ private String action; /** * Default constructor for AttributeValueUpdate object. Callers should use * the setter or fluent setter (with...) methods to initialize any * additional object members. */ public AttributeValueUpdate() { } /** * Constructs a new AttributeValueUpdate object. Callers should use the * setter or fluent setter (with...) methods to initialize any additional * object members. * * @param value

* Represents the data for an attribute. *

*

* Each attribute value is described as a name-value pair. The * name is the data type, and the value is the data itself. *

*

* For more information, see Data Types in the Amazon DynamoDB Developer Guide. *

* @param action

* Specifies how to perform the update. Valid values are * PUT (default), DELETE, and * ADD. The behavior depends on whether the * specified primary key already exists in the table. *

*

* If an item with the specified Key is found in the * table: *

* *

* If no item with the specified Key is found: *

* */ public AttributeValueUpdate(AttributeValue value, String action) { setValue(value); setAction(action); } /** * Constructs a new AttributeValueUpdate object. Callers should use the * setter or fluent setter (with...) methods to initialize any additional * object members. * * @param value

* Represents the data for an attribute. *

*

* Each attribute value is described as a name-value pair. The * name is the data type, and the value is the data itself. *

*

* For more information, see Data Types in the Amazon DynamoDB Developer Guide. *

* @param action

* Specifies how to perform the update. Valid values are * PUT (default), DELETE, and * ADD. The behavior depends on whether the * specified primary key already exists in the table. *

*

* If an item with the specified Key is found in the * table: *

* *

* If no item with the specified Key is found: *

* */ public AttributeValueUpdate(AttributeValue value, AttributeAction action) { setValue(value); setAction(action.toString()); } /** *

* Represents the data for an attribute. *

*

* Each attribute value is described as a name-value pair. The name is the * data type, and the value is the data itself. *

*

* For more information, see Data Types in the Amazon DynamoDB Developer Guide. *

* * @return

* Represents the data for an attribute. *

*

* Each attribute value is described as a name-value pair. The name * is the data type, and the value is the data itself. *

*

* For more information, see Data Types in the Amazon DynamoDB Developer Guide. *

*/ public AttributeValue getValue() { return value; } /** *

* Represents the data for an attribute. *

*

* Each attribute value is described as a name-value pair. The name is the * data type, and the value is the data itself. *

*

* For more information, see Data Types in the Amazon DynamoDB Developer Guide. *

* * @param value

* Represents the data for an attribute. *

*

* Each attribute value is described as a name-value pair. The * name is the data type, and the value is the data itself. *

*

* For more information, see Data Types in the Amazon DynamoDB Developer Guide. *

*/ public void setValue(AttributeValue value) { this.value = value; } /** *

* Represents the data for an attribute. *

*

* Each attribute value is described as a name-value pair. The name is the * data type, and the value is the data itself. *

*

* For more information, see Data Types in the Amazon DynamoDB Developer Guide. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param value

* Represents the data for an attribute. *

*

* Each attribute value is described as a name-value pair. The * name is the data type, and the value is the data itself. *

*

* For more information, see Data Types in the Amazon DynamoDB Developer Guide. *

* @return A reference to this updated object so that method calls can be * chained together. */ public AttributeValueUpdate withValue(AttributeValue value) { this.value = value; return this; } /** *

* Specifies how to perform the update. Valid values are PUT * (default), DELETE, and ADD. The behavior * depends on whether the specified primary key already exists in the table. *

*

* If an item with the specified Key is found in the table: *

* *

* If no item with the specified Key is found: *

* *

* Constraints:
* Allowed Values: ADD, PUT, DELETE * * @return

* Specifies how to perform the update. Valid values are * PUT (default), DELETE, and * ADD. The behavior depends on whether the specified * primary key already exists in the table. *

*

* If an item with the specified Key is found in the * table: *

* *

* If no item with the specified Key is found: *

* * @see AttributeAction */ public String getAction() { return action; } /** *

* Specifies how to perform the update. Valid values are PUT * (default), DELETE, and ADD. The behavior * depends on whether the specified primary key already exists in the table. *

*

* If an item with the specified Key is found in the table: *

* *

* If no item with the specified Key is found: *

* *

* Constraints:
* Allowed Values: ADD, PUT, DELETE * * @param action

* Specifies how to perform the update. Valid values are * PUT (default), DELETE, and * ADD. The behavior depends on whether the * specified primary key already exists in the table. *

*

* If an item with the specified Key is found in the * table: *

* *

* If no item with the specified Key is found: *

* * @see AttributeAction */ public void setAction(String action) { this.action = action; } /** *

* Specifies how to perform the update. Valid values are PUT * (default), DELETE, and ADD. The behavior * depends on whether the specified primary key already exists in the table. *

*

* If an item with the specified Key is found in the table: *

* *

* If no item with the specified Key is found: *

* *

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Allowed Values: ADD, PUT, DELETE * * @param action

* Specifies how to perform the update. Valid values are * PUT (default), DELETE, and * ADD. The behavior depends on whether the * specified primary key already exists in the table. *

*

* If an item with the specified Key is found in the * table: *

* *

* If no item with the specified Key is found: *

* * @return A reference to this updated object so that method calls can be * chained together. * @see AttributeAction */ public AttributeValueUpdate withAction(String action) { this.action = action; return this; } /** *

* Specifies how to perform the update. Valid values are PUT * (default), DELETE, and ADD. The behavior * depends on whether the specified primary key already exists in the table. *

*

* If an item with the specified Key is found in the table: *

* *

* If no item with the specified Key is found: *

* *

* Constraints:
* Allowed Values: ADD, PUT, DELETE * * @param action

* Specifies how to perform the update. Valid values are * PUT (default), DELETE, and * ADD. The behavior depends on whether the * specified primary key already exists in the table. *

*

* If an item with the specified Key is found in the * table: *

* *

* If no item with the specified Key is found: *

* * @see AttributeAction */ public void setAction(AttributeAction action) { this.action = action.toString(); } /** *

* Specifies how to perform the update. Valid values are PUT * (default), DELETE, and ADD. The behavior * depends on whether the specified primary key already exists in the table. *

*

* If an item with the specified Key is found in the table: *

* *

* If no item with the specified Key is found: *

* *

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Allowed Values: ADD, PUT, DELETE * * @param action

* Specifies how to perform the update. Valid values are * PUT (default), DELETE, and * ADD. The behavior depends on whether the * specified primary key already exists in the table. *

*

* If an item with the specified Key is found in the * table: *

* *

* If no item with the specified Key is found: *

* * @return A reference to this updated object so that method calls can be * chained together. * @see AttributeAction */ public AttributeValueUpdate withAction(AttributeAction action) { this.action = action.toString(); return this; } /** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getValue() != null) sb.append("Value: " + getValue() + ","); if (getAction() != null) sb.append("Action: " + getAction()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getValue() == null) ? 0 : getValue().hashCode()); hashCode = prime * hashCode + ((getAction() == null) ? 0 : getAction().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof AttributeValueUpdate == false) return false; AttributeValueUpdate other = (AttributeValueUpdate) obj; if (other.getValue() == null ^ this.getValue() == null) return false; if (other.getValue() != null && other.getValue().equals(this.getValue()) == false) return false; if (other.getAction() == null ^ this.getAction() == null) return false; if (other.getAction() != null && other.getAction().equals(this.getAction()) == false) return false; return true; } }