/* * 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.simpledb.model; import java.io.Serializable; import com.amazonaws.AmazonWebServiceRequest; /** * Container for the parameters to the {@link com.amazonaws.services.simpledb.AmazonSimpleDB#putAttributes(PutAttributesRequest) PutAttributes operation}. *
* The PutAttributes operation creates or replaces attributes in an
* item. The client may specify new attributes using a combination of the
* Attribute.X.Name
and Attribute.X.Value
* parameters. The client specifies the first attribute by the parameters
* Attribute.0.Name
and Attribute.0.Value
,
* the second attribute by the parameters Attribute.1.Name
* and Attribute.1.Value
, and so on.
*
* Attributes are uniquely identified in an item by their name/value
* combination. For example, a single item can have the attributes
* { "first_name", "first_value" }
and { "first_name",
* second_value" }
. However, it cannot have two attribute
* instances where both the Attribute.X.Name
and
* Attribute.X.Value
are the same.
*
* Optionally, the requestor can supply the Replace
* parameter for each individual attribute. Setting this value to
* true
causes the new attribute value to replace the
* existing attribute value(s). For example, if an item has the
* attributes { 'a', '1' }
,
*
* { 'b', '2'}
and { 'b', '3'
* }
and the requestor calls PutAttributes
using the
* attributes { 'b', '4' }
with the Replace
* parameter set to true, the final attributes of the item are changed to
* { 'a', '1' }
and { 'b', '4' }
, which
* replaces the previous values of the 'b' attribute with the new value.
*
* NOTE: Using PutAttributes to replace attribute values that do * not exist will not result in an error response. *
** You cannot specify an empty string as an attribute name. *
** Because Amazon SimpleDB makes multiple copies of client data and uses * an eventual consistency update model, an immediate GetAttributes or * Select operation (read) immediately after a PutAttributes or * DeleteAttributes operation (write) might not return the updated data. *
** The following limitations are enforced for this operation: *
* Returns a reference to this object so that method calls can be chained together. * * @param domainName The name of the domain in which to perform the operation. * * @return A reference to this updated object so that method calls can be chained * together. */ public PutAttributesRequest withDomainName(String domainName) { this.domainName = domainName; return this; } /** * The name of the item. * * @return The name of the item. */ public String getItemName() { return itemName; } /** * The name of the item. * * @param itemName The name of the item. */ public void setItemName(String itemName) { this.itemName = itemName; } /** * The name of the item. *
* Returns a reference to this object so that method calls can be chained together.
*
* @param itemName The name of the item.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public PutAttributesRequest withItemName(String itemName) {
this.itemName = itemName;
return this;
}
/**
* The list of attributes.
*
* @return The list of attributes.
*/
public java.util.List
* Returns a reference to this object so that method calls can be chained together.
*
* @param attributes The list of attributes.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public PutAttributesRequest withAttributes(ReplaceableAttribute... attributes) {
if (getAttributes() == null) setAttributes(new java.util.ArrayList
* Returns a reference to this object so that method calls can be chained together.
*
* @param attributes The list of attributes.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public PutAttributesRequest withAttributes(java.util.Collection
* Returns a reference to this object so that method calls can be chained together.
*
* @param expected The update condition which, if specified, determines whether the
* specified attributes will be updated or not. The update condition must
* be satisfied in order for this request to be processed and the
* attributes to be updated.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public PutAttributesRequest withExpected(UpdateCondition expected) {
this.expected = expected;
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 (getDomainName() != null) sb.append("DomainName: " + getDomainName() + ",");
if (getItemName() != null) sb.append("ItemName: " + getItemName() + ",");
if (getAttributes() != null) sb.append("Attributes: " + getAttributes() + ",");
if (getExpected() != null) sb.append("Expected: " + getExpected() );
sb.append("}");
return sb.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getDomainName() == null) ? 0 : getDomainName().hashCode());
hashCode = prime * hashCode + ((getItemName() == null) ? 0 : getItemName().hashCode());
hashCode = prime * hashCode + ((getAttributes() == null) ? 0 : getAttributes().hashCode());
hashCode = prime * hashCode + ((getExpected() == null) ? 0 : getExpected().hashCode());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (obj instanceof PutAttributesRequest == false) return false;
PutAttributesRequest other = (PutAttributesRequest)obj;
if (other.getDomainName() == null ^ this.getDomainName() == null) return false;
if (other.getDomainName() != null && other.getDomainName().equals(this.getDomainName()) == false) return false;
if (other.getItemName() == null ^ this.getItemName() == null) return false;
if (other.getItemName() != null && other.getItemName().equals(this.getItemName()) == false) return false;
if (other.getAttributes() == null ^ this.getAttributes() == null) return false;
if (other.getAttributes() != null && other.getAttributes().equals(this.getAttributes()) == false) return false;
if (other.getExpected() == null ^ this.getExpected() == null) return false;
if (other.getExpected() != null && other.getExpected().equals(this.getExpected()) == false) return false;
return true;
}
}