main.java.com.amazonaws.services.dynamodbv2.model.KeysAndAttributes Maven / Gradle / Ivy
Show all versions of aws-android-sdk-s3 Show documentation
/*
* Copyright 2010-2015 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;
/**
*
* Represents a set of primary keys and, for each key, the attributes to
* retrieve from the table.
*
*/
public class KeysAndAttributes implements Serializable {
/**
* The primary key attribute values that define the items and the
* attributes associated with the items.
*
* Constraints:
* Length: 1 - 100
*/
private com.amazonaws.internal.ListWithAutoConstructFlag> keys;
/**
* One or more attributes to retrieve from the table or index. If no
* attribute names are specified then all attributes will be returned. If
* any of the specified attributes are not found, they will not appear in
* the result.
*
* Constraints:
* Length: 1 -
*/
private com.amazonaws.internal.ListWithAutoConstructFlag attributesToGet;
/**
* The consistency of a read operation. If set to true
, then
* a strongly consistent read is used; otherwise, an eventually
* consistent read is used.
*/
private Boolean consistentRead;
private String projectionExpression;
private java.util.Map expressionAttributeNames;
/**
* The primary key attribute values that define the items and the
* attributes associated with the items.
*
* Constraints:
* Length: 1 - 100
*
* @return The primary key attribute values that define the items and the
* attributes associated with the items.
*/
public java.util.List> getKeys() {
return keys;
}
/**
* The primary key attribute values that define the items and the
* attributes associated with the items.
*
* Constraints:
* Length: 1 - 100
*
* @param keys The primary key attribute values that define the items and the
* attributes associated with the items.
*/
public void setKeys(java.util.Collection> keys) {
if (keys == null) {
this.keys = null;
return;
}
com.amazonaws.internal.ListWithAutoConstructFlag> keysCopy = new com.amazonaws.internal.ListWithAutoConstructFlag>(keys.size());
keysCopy.addAll(keys);
this.keys = keysCopy;
}
/**
* The primary key attribute values that define the items and the
* attributes associated with the items.
*
* Returns a reference to this object so that method calls can be chained together.
*
* Constraints:
* Length: 1 - 100
*
* @param keys The primary key attribute values that define the items and the
* attributes associated with the items.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public KeysAndAttributes withKeys(java.util.Map... keys) {
if (getKeys() == null) setKeys(new java.util.ArrayList>(keys.length));
for (java.util.Map value : keys) {
getKeys().add(value);
}
return this;
}
/**
* The primary key attribute values that define the items and the
* attributes associated with the items.
*
* Returns a reference to this object so that method calls can be chained together.
*
* Constraints:
* Length: 1 - 100
*
* @param keys The primary key attribute values that define the items and the
* attributes associated with the items.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public KeysAndAttributes withKeys(java.util.Collection> keys) {
if (keys == null) {
this.keys = null;
} else {
com.amazonaws.internal.ListWithAutoConstructFlag> keysCopy = new com.amazonaws.internal.ListWithAutoConstructFlag>(keys.size());
keysCopy.addAll(keys);
this.keys = keysCopy;
}
return this;
}
/**
* One or more attributes to retrieve from the table or index. If no
* attribute names are specified then all attributes will be returned. If
* any of the specified attributes are not found, they will not appear in
* the result.
*
* Constraints:
* Length: 1 -
*
* @return One or more attributes to retrieve from the table or index. If no
* attribute names are specified then all attributes will be returned. If
* any of the specified attributes are not found, they will not appear in
* the result.
*/
public java.util.List getAttributesToGet() {
return attributesToGet;
}
/**
* One or more attributes to retrieve from the table or index. If no
* attribute names are specified then all attributes will be returned. If
* any of the specified attributes are not found, they will not appear in
* the result.
*
* Constraints:
* Length: 1 -
*
* @param attributesToGet One or more attributes to retrieve from the table or index. If no
* attribute names are specified then all attributes will be returned. If
* any of the specified attributes are not found, they will not appear in
* the result.
*/
public void setAttributesToGet(java.util.Collection attributesToGet) {
if (attributesToGet == null) {
this.attributesToGet = null;
return;
}
com.amazonaws.internal.ListWithAutoConstructFlag attributesToGetCopy = new com.amazonaws.internal.ListWithAutoConstructFlag(attributesToGet.size());
attributesToGetCopy.addAll(attributesToGet);
this.attributesToGet = attributesToGetCopy;
}
/**
* One or more attributes to retrieve from the table or index. If no
* attribute names are specified then all attributes will be returned. If
* any of the specified attributes are not found, they will not appear in
* the result.
*
* Returns a reference to this object so that method calls can be chained together.
*
* Constraints:
* Length: 1 -
*
* @param attributesToGet One or more attributes to retrieve from the table or index. If no
* attribute names are specified then all attributes will be returned. If
* any of the specified attributes are not found, they will not appear in
* the result.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public KeysAndAttributes withAttributesToGet(String... attributesToGet) {
if (getAttributesToGet() == null) setAttributesToGet(new java.util.ArrayList(attributesToGet.length));
for (String value : attributesToGet) {
getAttributesToGet().add(value);
}
return this;
}
/**
* One or more attributes to retrieve from the table or index. If no
* attribute names are specified then all attributes will be returned. If
* any of the specified attributes are not found, they will not appear in
* the result.
*
* Returns a reference to this object so that method calls can be chained together.
*
* Constraints:
* Length: 1 -
*
* @param attributesToGet One or more attributes to retrieve from the table or index. If no
* attribute names are specified then all attributes will be returned. If
* any of the specified attributes are not found, they will not appear in
* the result.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public KeysAndAttributes withAttributesToGet(java.util.Collection attributesToGet) {
if (attributesToGet == null) {
this.attributesToGet = null;
} else {
com.amazonaws.internal.ListWithAutoConstructFlag attributesToGetCopy = new com.amazonaws.internal.ListWithAutoConstructFlag(attributesToGet.size());
attributesToGetCopy.addAll(attributesToGet);
this.attributesToGet = attributesToGetCopy;
}
return this;
}
/**
* The consistency of a read operation. If set to true
, then
* a strongly consistent read is used; otherwise, an eventually
* consistent read is used.
*
* @return The consistency of a read operation. If set to true
, then
* a strongly consistent read is used; otherwise, an eventually
* consistent read is used.
*/
public Boolean isConsistentRead() {
return consistentRead;
}
/**
* The consistency of a read operation. If set to true
, then
* a strongly consistent read is used; otherwise, an eventually
* consistent read is used.
*
* @param consistentRead The consistency of a read operation. If set to true
, then
* a strongly consistent read is used; otherwise, an eventually
* consistent read is used.
*/
public void setConsistentRead(Boolean consistentRead) {
this.consistentRead = consistentRead;
}
/**
* The consistency of a read operation. If set to true
, then
* a strongly consistent read is used; otherwise, an eventually
* consistent read is used.
*
* Returns a reference to this object so that method calls can be chained together.
*
* @param consistentRead The consistency of a read operation. If set to true
, then
* a strongly consistent read is used; otherwise, an eventually
* consistent read is used.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public KeysAndAttributes withConsistentRead(Boolean consistentRead) {
this.consistentRead = consistentRead;
return this;
}
/**
* The consistency of a read operation. If set to true
, then
* a strongly consistent read is used; otherwise, an eventually
* consistent read is used.
*
* @return The consistency of a read operation. If set to true
, then
* a strongly consistent read is used; otherwise, an eventually
* consistent read is used.
*/
public Boolean getConsistentRead() {
return consistentRead;
}
/**
* Returns the value of the ProjectionExpression property for this
* object.
*
* @return The value of the ProjectionExpression property for this object.
*/
public String getProjectionExpression() {
return projectionExpression;
}
/**
* Sets the value of the ProjectionExpression property for this object.
*
* @param projectionExpression The new value for the ProjectionExpression property for this object.
*/
public void setProjectionExpression(String projectionExpression) {
this.projectionExpression = projectionExpression;
}
/**
* Sets the value of the ProjectionExpression property for this object.
*
* Returns a reference to this object so that method calls can be chained together.
*
* @param projectionExpression The new value for the ProjectionExpression property for this object.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public KeysAndAttributes withProjectionExpression(String projectionExpression) {
this.projectionExpression = projectionExpression;
return this;
}
/**
* Returns the value of the ExpressionAttributeNames property for this
* object.
*
* @return The value of the ExpressionAttributeNames property for this object.
*/
public java.util.Map getExpressionAttributeNames() {
return expressionAttributeNames;
}
/**
* Sets the value of the ExpressionAttributeNames property for this
* object.
*
* @param expressionAttributeNames The new value for the ExpressionAttributeNames property for this
* object.
*/
public void setExpressionAttributeNames(java.util.Map expressionAttributeNames) {
this.expressionAttributeNames = expressionAttributeNames;
}
/**
* Sets the value of the ExpressionAttributeNames property for this
* object.
*
* Returns a reference to this object so that method calls can be chained together.
*
* @param expressionAttributeNames The new value for the ExpressionAttributeNames property for this
* object.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public KeysAndAttributes withExpressionAttributeNames(java.util.Map expressionAttributeNames) {
setExpressionAttributeNames(expressionAttributeNames);
return this;
}
/**
* Sets the value of the ExpressionAttributeNames property for this
* object.
*
* The method adds a new key-value pair into ExpressionAttributeNames
* parameter, and returns a reference to this object so that method calls
* can be chained together.
*
* @param key The key of the entry to be added into ExpressionAttributeNames.
* @param value The corresponding value of the entry to be added into ExpressionAttributeNames.
*/
public KeysAndAttributes addExpressionAttributeNamesEntry(String key, String value) {
if (null == this.expressionAttributeNames) {
this.expressionAttributeNames = new java.util.HashMap();
}
if (this.expressionAttributeNames.containsKey(key))
throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
this.expressionAttributeNames.put(key, value);
return this;
}
/**
* Removes all the entries added into ExpressionAttributeNames.
*
* Returns a reference to this object so that method calls can be chained together.
*/
public KeysAndAttributes clearExpressionAttributeNamesEntries() {
this.expressionAttributeNames = null;
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 (getKeys() != null) sb.append("Keys: " + getKeys() + ",");
if (getAttributesToGet() != null) sb.append("AttributesToGet: " + getAttributesToGet() + ",");
if (isConsistentRead() != null) sb.append("ConsistentRead: " + isConsistentRead() + ",");
if (getProjectionExpression() != null) sb.append("ProjectionExpression: " + getProjectionExpression() + ",");
if (getExpressionAttributeNames() != null) sb.append("ExpressionAttributeNames: " + getExpressionAttributeNames() );
sb.append("}");
return sb.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getKeys() == null) ? 0 : getKeys().hashCode());
hashCode = prime * hashCode + ((getAttributesToGet() == null) ? 0 : getAttributesToGet().hashCode());
hashCode = prime * hashCode + ((isConsistentRead() == null) ? 0 : isConsistentRead().hashCode());
hashCode = prime * hashCode + ((getProjectionExpression() == null) ? 0 : getProjectionExpression().hashCode());
hashCode = prime * hashCode + ((getExpressionAttributeNames() == null) ? 0 : getExpressionAttributeNames().hashCode());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (obj instanceof KeysAndAttributes == false) return false;
KeysAndAttributes other = (KeysAndAttributes)obj;
if (other.getKeys() == null ^ this.getKeys() == null) return false;
if (other.getKeys() != null && other.getKeys().equals(this.getKeys()) == false) return false;
if (other.getAttributesToGet() == null ^ this.getAttributesToGet() == null) return false;
if (other.getAttributesToGet() != null && other.getAttributesToGet().equals(this.getAttributesToGet()) == false) return false;
if (other.isConsistentRead() == null ^ this.isConsistentRead() == null) return false;
if (other.isConsistentRead() != null && other.isConsistentRead().equals(this.isConsistentRead()) == false) return false;
if (other.getProjectionExpression() == null ^ this.getProjectionExpression() == null) return false;
if (other.getProjectionExpression() != null && other.getProjectionExpression().equals(this.getProjectionExpression()) == false) return false;
if (other.getExpressionAttributeNames() == null ^ this.getExpressionAttributeNames() == null) return false;
if (other.getExpressionAttributeNames() != null && other.getExpressionAttributeNames().equals(this.getExpressionAttributeNames()) == false) return false;
return true;
}
}