com.amazonaws.services.dynamodb.model.PutItemRequest Maven / Gradle / Ivy
Show all versions of aws-java-sdk Show documentation
/*
* Copyright 2010-2014 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.dynamodb.model;
import com.amazonaws.AmazonWebServiceRequest;
import java.io.Serializable;
/**
* Container for the parameters to the {@link com.amazonaws.services.dynamodb.AmazonDynamoDB#putItem(PutItemRequest) PutItem operation}.
*
* Creates a new item, or replaces an old item with a new item (including all the attributes).
*
*
* If an item already exists in the specified table with the same primary key, the new item completely replaces the existing item. You can perform a
* conditional put (insert a new item if one with the specified primary key doesn't exist), or replace an existing item if it has certain attribute
* values.
*
*
* @see com.amazonaws.services.dynamodb.AmazonDynamoDB#putItem(PutItemRequest)
*
* @deprecated Use {@link com.amazonaws.services.dynamodbv2.model.PutItemRequest} instead.
*/
@Deprecated
public class PutItemRequest extends AmazonWebServiceRequest implements Serializable {
/**
* The name of the table in which you want to put an item. Allowed
* characters are a-z
, A-Z
, 0-9
,
* _
(underscore), -
(hyphen) and
* .
(period).
*
* Constraints:
* Length: 3 - 255
* Pattern: [a-zA-Z0-9_.-]+
*/
private String tableName;
/**
* A map of the attributes for the item, and must include the primary key
* values that define the item. Other attribute name-value pairs can be
* provided for the item.
*/
private java.util.Map item;
/**
* Designates an attribute for a conditional modification. The
* Expected
parameter allows you to provide an attribute
* name, and whether or not Amazon DynamoDB should check to see if the
* attribute has a particular value before modifying it.
*/
private java.util.Map expected;
/**
* Use this parameter if you want to get the attribute name-value pairs
* before or after they are modified. For PUT
operations,
* the possible parameter values are NONE
(default) or
* ALL_OLD
. For update operations, the possible parameter
* values are NONE
(default) or ALL_OLD
,
* UPDATED_OLD
, ALL_NEW
or
* UPDATED_NEW
. NONE
: Nothing is
* returned. ALL_OLD
: Returns the attributes of the
* item as they were before the operation.
* UPDATED_OLD
: Returns the values of the updated
* attributes, only, as they were before the operation.
* ALL_NEW
: Returns all the attributes and their new
* values after the operation. UPDATED_NEW
: Returns
* the values of the updated attributes, only, as they are after the
* operation.
*
* Constraints:
* Allowed Values: NONE, ALL_OLD, UPDATED_OLD, ALL_NEW, UPDATED_NEW
*/
private String returnValues;
/**
* Default constructor for a new PutItemRequest object. Callers should use the
* setter or fluent setter (with...) methods to initialize this object after creating it.
*/
public PutItemRequest() {}
/**
* Constructs a new PutItemRequest object.
* Callers should use the setter or fluent setter (with...) methods to
* initialize any additional object members.
*
* @param tableName The name of the table in which you want to put an
* item. Allowed characters are a-z
, A-Z
,
* 0-9
, _
(underscore), -
(hyphen)
* and .
(period).
* @param item A map of the attributes for the item, and must include the
* primary key values that define the item. Other attribute name-value
* pairs can be provided for the item.
*/
public PutItemRequest(String tableName, java.util.Map item) {
this.tableName = tableName;
this.item = item;
}
/**
* The name of the table in which you want to put an item. Allowed
* characters are a-z
, A-Z
, 0-9
,
* _
(underscore), -
(hyphen) and
* .
(period).
*
* Constraints:
* Length: 3 - 255
* Pattern: [a-zA-Z0-9_.-]+
*
* @return The name of the table in which you want to put an item. Allowed
* characters are a-z
, A-Z
, 0-9
,
* _
(underscore), -
(hyphen) and
* .
(period).
*/
public String getTableName() {
return tableName;
}
/**
* The name of the table in which you want to put an item. Allowed
* characters are a-z
, A-Z
, 0-9
,
* _
(underscore), -
(hyphen) and
* .
(period).
*
* Constraints:
* Length: 3 - 255
* Pattern: [a-zA-Z0-9_.-]+
*
* @param tableName The name of the table in which you want to put an item. Allowed
* characters are a-z
, A-Z
, 0-9
,
* _
(underscore), -
(hyphen) and
* .
(period).
*/
public void setTableName(String tableName) {
this.tableName = tableName;
}
/**
* The name of the table in which you want to put an item. Allowed
* characters are a-z
, A-Z
, 0-9
,
* _
(underscore), -
(hyphen) and
* .
(period).
*
* Returns a reference to this object so that method calls can be chained together.
*
* Constraints:
* Length: 3 - 255
* Pattern: [a-zA-Z0-9_.-]+
*
* @param tableName The name of the table in which you want to put an item. Allowed
* characters are a-z
, A-Z
, 0-9
,
* _
(underscore), -
(hyphen) and
* .
(period).
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public PutItemRequest withTableName(String tableName) {
this.tableName = tableName;
return this;
}
/**
* A map of the attributes for the item, and must include the primary key
* values that define the item. Other attribute name-value pairs can be
* provided for the item.
*
* @return A map of the attributes for the item, and must include the primary key
* values that define the item. Other attribute name-value pairs can be
* provided for the item.
*/
public java.util.Map getItem() {
return item;
}
/**
* A map of the attributes for the item, and must include the primary key
* values that define the item. Other attribute name-value pairs can be
* provided for the item.
*
* @param item A map of the attributes for the item, and must include the primary key
* values that define the item. Other attribute name-value pairs can be
* provided for the item.
*/
public void setItem(java.util.Map item) {
this.item = item;
}
/**
* A map of the attributes for the item, and must include the primary key
* values that define the item. Other attribute name-value pairs can be
* provided for the item.
*
* Returns a reference to this object so that method calls can be chained together.
*
* @param item A map of the attributes for the item, and must include the primary key
* values that define the item. Other attribute name-value pairs can be
* provided for the item.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public PutItemRequest withItem(java.util.Map item) {
setItem(item);
return this;
}
/**
* Designates an attribute for a conditional modification. The
* Expected
parameter allows you to provide an attribute
* name, and whether or not Amazon DynamoDB should check to see if the
* attribute has a particular value before modifying it.
*
* @return Designates an attribute for a conditional modification. The
* Expected
parameter allows you to provide an attribute
* name, and whether or not Amazon DynamoDB should check to see if the
* attribute has a particular value before modifying it.
*/
public java.util.Map getExpected() {
return expected;
}
/**
* Designates an attribute for a conditional modification. The
* Expected
parameter allows you to provide an attribute
* name, and whether or not Amazon DynamoDB should check to see if the
* attribute has a particular value before modifying it.
*
* @param expected Designates an attribute for a conditional modification. The
* Expected
parameter allows you to provide an attribute
* name, and whether or not Amazon DynamoDB should check to see if the
* attribute has a particular value before modifying it.
*/
public void setExpected(java.util.Map expected) {
this.expected = expected;
}
/**
* Designates an attribute for a conditional modification. The
* Expected
parameter allows you to provide an attribute
* name, and whether or not Amazon DynamoDB should check to see if the
* attribute has a particular value before modifying it.
*
* Returns a reference to this object so that method calls can be chained together.
*
* @param expected Designates an attribute for a conditional modification. The
* Expected
parameter allows you to provide an attribute
* name, and whether or not Amazon DynamoDB should check to see if the
* attribute has a particular value before modifying it.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public PutItemRequest withExpected(java.util.Map expected) {
setExpected(expected);
return this;
}
/**
* Use this parameter if you want to get the attribute name-value pairs
* before or after they are modified. For PUT
operations,
* the possible parameter values are NONE
(default) or
* ALL_OLD
. For update operations, the possible parameter
* values are NONE
(default) or ALL_OLD
,
* UPDATED_OLD
, ALL_NEW
or
* UPDATED_NEW
. NONE
: Nothing is
* returned. ALL_OLD
: Returns the attributes of the
* item as they were before the operation.
* UPDATED_OLD
: Returns the values of the updated
* attributes, only, as they were before the operation.
* ALL_NEW
: Returns all the attributes and their new
* values after the operation. UPDATED_NEW
: Returns
* the values of the updated attributes, only, as they are after the
* operation.
*
* Constraints:
* Allowed Values: NONE, ALL_OLD, UPDATED_OLD, ALL_NEW, UPDATED_NEW
*
* @return Use this parameter if you want to get the attribute name-value pairs
* before or after they are modified. For PUT
operations,
* the possible parameter values are NONE
(default) or
* ALL_OLD
. For update operations, the possible parameter
* values are NONE
(default) or ALL_OLD
,
* UPDATED_OLD
, ALL_NEW
or
* UPDATED_NEW
.
NONE
: Nothing is
* returned. ALL_OLD
: Returns the attributes of the
* item as they were before the operation.
* UPDATED_OLD
: Returns the values of the updated
* attributes, only, as they were before the operation.
* ALL_NEW
: Returns all the attributes and their new
* values after the operation. UPDATED_NEW
: Returns
* the values of the updated attributes, only, as they are after the
* operation.
*
* @see ReturnValue
*/
public String getReturnValues() {
return returnValues;
}
/**
* Use this parameter if you want to get the attribute name-value pairs
* before or after they are modified. For PUT
operations,
* the possible parameter values are NONE
(default) or
* ALL_OLD
. For update operations, the possible parameter
* values are NONE
(default) or ALL_OLD
,
* UPDATED_OLD
, ALL_NEW
or
* UPDATED_NEW
. NONE
: Nothing is
* returned. ALL_OLD
: Returns the attributes of the
* item as they were before the operation.
* UPDATED_OLD
: Returns the values of the updated
* attributes, only, as they were before the operation.
* ALL_NEW
: Returns all the attributes and their new
* values after the operation. UPDATED_NEW
: Returns
* the values of the updated attributes, only, as they are after the
* operation.
*
* Constraints:
* Allowed Values: NONE, ALL_OLD, UPDATED_OLD, ALL_NEW, UPDATED_NEW
*
* @param returnValues Use this parameter if you want to get the attribute name-value pairs
* before or after they are modified. For PUT
operations,
* the possible parameter values are NONE
(default) or
* ALL_OLD
. For update operations, the possible parameter
* values are NONE
(default) or ALL_OLD
,
* UPDATED_OLD
, ALL_NEW
or
* UPDATED_NEW
.
NONE
: Nothing is
* returned. ALL_OLD
: Returns the attributes of the
* item as they were before the operation.
* UPDATED_OLD
: Returns the values of the updated
* attributes, only, as they were before the operation.
* ALL_NEW
: Returns all the attributes and their new
* values after the operation. UPDATED_NEW
: Returns
* the values of the updated attributes, only, as they are after the
* operation.
*
* @see ReturnValue
*/
public void setReturnValues(String returnValues) {
this.returnValues = returnValues;
}
/**
* Use this parameter if you want to get the attribute name-value pairs
* before or after they are modified. For PUT
operations,
* the possible parameter values are NONE
(default) or
* ALL_OLD
. For update operations, the possible parameter
* values are NONE
(default) or ALL_OLD
,
* UPDATED_OLD
, ALL_NEW
or
* UPDATED_NEW
. NONE
: Nothing is
* returned. ALL_OLD
: Returns the attributes of the
* item as they were before the operation.
* UPDATED_OLD
: Returns the values of the updated
* attributes, only, as they were before the operation.
* ALL_NEW
: Returns all the attributes and their new
* values after the operation. UPDATED_NEW
: Returns
* the values of the updated attributes, only, as they are after the
* operation.
*
* Returns a reference to this object so that method calls can be chained together.
*
* Constraints:
* Allowed Values: NONE, ALL_OLD, UPDATED_OLD, ALL_NEW, UPDATED_NEW
*
* @param returnValues Use this parameter if you want to get the attribute name-value pairs
* before or after they are modified. For PUT
operations,
* the possible parameter values are NONE
(default) or
* ALL_OLD
. For update operations, the possible parameter
* values are NONE
(default) or ALL_OLD
,
* UPDATED_OLD
, ALL_NEW
or
* UPDATED_NEW
.
NONE
: Nothing is
* returned. ALL_OLD
: Returns the attributes of the
* item as they were before the operation.
* UPDATED_OLD
: Returns the values of the updated
* attributes, only, as they were before the operation.
* ALL_NEW
: Returns all the attributes and their new
* values after the operation. UPDATED_NEW
: Returns
* the values of the updated attributes, only, as they are after the
* operation.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*
* @see ReturnValue
*/
public PutItemRequest withReturnValues(String returnValues) {
this.returnValues = returnValues;
return this;
}
/**
* Use this parameter if you want to get the attribute name-value pairs
* before or after they are modified. For PUT
operations,
* the possible parameter values are NONE
(default) or
* ALL_OLD
. For update operations, the possible parameter
* values are NONE
(default) or ALL_OLD
,
* UPDATED_OLD
, ALL_NEW
or
* UPDATED_NEW
. NONE
: Nothing is
* returned. ALL_OLD
: Returns the attributes of the
* item as they were before the operation.
* UPDATED_OLD
: Returns the values of the updated
* attributes, only, as they were before the operation.
* ALL_NEW
: Returns all the attributes and their new
* values after the operation. UPDATED_NEW
: Returns
* the values of the updated attributes, only, as they are after the
* operation.
*
* Constraints:
* Allowed Values: NONE, ALL_OLD, UPDATED_OLD, ALL_NEW, UPDATED_NEW
*
* @param returnValues Use this parameter if you want to get the attribute name-value pairs
* before or after they are modified. For PUT
operations,
* the possible parameter values are NONE
(default) or
* ALL_OLD
. For update operations, the possible parameter
* values are NONE
(default) or ALL_OLD
,
* UPDATED_OLD
, ALL_NEW
or
* UPDATED_NEW
.
NONE
: Nothing is
* returned. ALL_OLD
: Returns the attributes of the
* item as they were before the operation.
* UPDATED_OLD
: Returns the values of the updated
* attributes, only, as they were before the operation.
* ALL_NEW
: Returns all the attributes and their new
* values after the operation. UPDATED_NEW
: Returns
* the values of the updated attributes, only, as they are after the
* operation.
*
* @see ReturnValue
*/
public void setReturnValues(ReturnValue returnValues) {
this.returnValues = returnValues.toString();
}
/**
* Use this parameter if you want to get the attribute name-value pairs
* before or after they are modified. For PUT
operations,
* the possible parameter values are NONE
(default) or
* ALL_OLD
. For update operations, the possible parameter
* values are NONE
(default) or ALL_OLD
,
* UPDATED_OLD
, ALL_NEW
or
* UPDATED_NEW
. NONE
: Nothing is
* returned. ALL_OLD
: Returns the attributes of the
* item as they were before the operation.
* UPDATED_OLD
: Returns the values of the updated
* attributes, only, as they were before the operation.
* ALL_NEW
: Returns all the attributes and their new
* values after the operation. UPDATED_NEW
: Returns
* the values of the updated attributes, only, as they are after the
* operation.
*
* Returns a reference to this object so that method calls can be chained together.
*
* Constraints:
* Allowed Values: NONE, ALL_OLD, UPDATED_OLD, ALL_NEW, UPDATED_NEW
*
* @param returnValues Use this parameter if you want to get the attribute name-value pairs
* before or after they are modified. For PUT
operations,
* the possible parameter values are NONE
(default) or
* ALL_OLD
. For update operations, the possible parameter
* values are NONE
(default) or ALL_OLD
,
* UPDATED_OLD
, ALL_NEW
or
* UPDATED_NEW
.
NONE
: Nothing is
* returned. ALL_OLD
: Returns the attributes of the
* item as they were before the operation.
* UPDATED_OLD
: Returns the values of the updated
* attributes, only, as they were before the operation.
* ALL_NEW
: Returns all the attributes and their new
* values after the operation. UPDATED_NEW
: Returns
* the values of the updated attributes, only, as they are after the
* operation.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*
* @see ReturnValue
*/
public PutItemRequest withReturnValues(ReturnValue returnValues) {
this.returnValues = returnValues.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 (getTableName() != null) sb.append("TableName: " + getTableName() + ", ");
if (getItem() != null) sb.append("Item: " + getItem() + ", ");
if (getExpected() != null) sb.append("Expected: " + getExpected() + ", ");
if (getReturnValues() != null) sb.append("ReturnValues: " + getReturnValues() + ", ");
sb.append("}");
return sb.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getTableName() == null) ? 0 : getTableName().hashCode());
hashCode = prime * hashCode + ((getItem() == null) ? 0 : getItem().hashCode());
hashCode = prime * hashCode + ((getExpected() == null) ? 0 : getExpected().hashCode());
hashCode = prime * hashCode + ((getReturnValues() == null) ? 0 : getReturnValues().hashCode());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (obj instanceof PutItemRequest == false) return false;
PutItemRequest other = (PutItemRequest)obj;
if (other.getTableName() == null ^ this.getTableName() == null) return false;
if (other.getTableName() != null && other.getTableName().equals(this.getTableName()) == false) return false;
if (other.getItem() == null ^ this.getItem() == null) return false;
if (other.getItem() != null && other.getItem().equals(this.getItem()) == false) return false;
if (other.getExpected() == null ^ this.getExpected() == null) return false;
if (other.getExpected() != null && other.getExpected().equals(this.getExpected()) == false) return false;
if (other.getReturnValues() == null ^ this.getReturnValues() == null) return false;
if (other.getReturnValues() != null && other.getReturnValues().equals(this.getReturnValues()) == false) return false;
return true;
}
}