All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.amazonaws.services.dynamodbv2.model.KeysAndAttributes Maven / Gradle / Ivy

/*
 * Copyright 2010-2018 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. *

*

* For each primary key, you must provide all of the key attributes. For * example, with a simple primary key, you only need to provide the partition * key. For a composite primary key, you must provide both the partition * key and the sort key. *

*/ public class KeysAndAttributes implements Serializable { /** *

* The primary key attribute values that define the items and the attributes * associated with the items. *

*/ private java.util.List> keys; /** *

* This is a legacy parameter. Use ProjectionExpression * instead. For more information, see Legacy Conditional Parameters in the Amazon DynamoDB Developer * Guide. *

*/ private java.util.List 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; /** *

* A string that identifies one or more attributes to retrieve from the * table. These attributes can include scalars, sets, or elements of a JSON * document. The attributes in the ProjectionExpression must be * separated by commas. *

*

* If no attribute names are specified, then all attributes will be * returned. If any of the requested attributes are not found, they will not * appear in the result. *

*

* For more information, see Accessing Item Attributes in the Amazon DynamoDB Developer * Guide. *

*/ private String projectionExpression; /** *

* One or more substitution tokens for attribute names in an expression. The * following are some use cases for using * ExpressionAttributeNames: *

*
    *
  • *

    * To access an attribute whose name conflicts with a DynamoDB reserved * word. *

    *
  • *
  • *

    * To create a placeholder for repeating occurrences of an attribute name in * an expression. *

    *
  • *
  • *

    * To prevent special characters in an attribute name from being * misinterpreted in an expression. *

    *
  • *
*

* Use the # character in an expression to dereference an attribute * name. For example, consider the following attribute name: *

*
    *
  • *

    * Percentile *

    *
  • *
*

* The name of this attribute conflicts with a reserved word, so it cannot * be used directly in an expression. (For the complete list of reserved * words, see Reserved Words in the Amazon DynamoDB Developer Guide). To * work around this, you could specify the following for * ExpressionAttributeNames: *

*
    *
  • *

    * {"#P":"Percentile"} *

    *
  • *
*

* You could then use this substitution in an expression, as in this * example: *

*
    *
  • *

    * #P = :val *

    *
  • *
* *

* Tokens that begin with the : character are expression attribute * values, which are placeholders for the actual value at runtime. *

*
*

* For more information on expression attribute names, see Accessing Item Attributes in the Amazon DynamoDB Developer * Guide. *

*/ private java.util.Map expressionAttributeNames; /** *

* The primary key attribute values that define the items and the attributes * associated with the items. *

* * @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. *

* * @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; } this.keys = new java.util.ArrayList>(keys); } /** *

* 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. * * @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) { this.keys = new java.util.ArrayList>(keys.length); } for (java.util.Map value : keys) { this.keys.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. * * @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) { setKeys(keys); return this; } /** *

* This is a legacy parameter. Use ProjectionExpression * instead. For more information, see Legacy Conditional Parameters in the Amazon DynamoDB Developer * Guide. *

* * @return

* This is a legacy parameter. Use ProjectionExpression * instead. For more information, see Legacy Conditional Parameters in the Amazon DynamoDB * Developer Guide. *

*/ public java.util.List getAttributesToGet() { return attributesToGet; } /** *

* This is a legacy parameter. Use ProjectionExpression * instead. For more information, see Legacy Conditional Parameters in the Amazon DynamoDB Developer * Guide. *

* * @param attributesToGet

* This is a legacy parameter. Use * ProjectionExpression instead. For more * information, see Legacy Conditional Parameters in the Amazon DynamoDB * Developer Guide. *

*/ public void setAttributesToGet(java.util.Collection attributesToGet) { if (attributesToGet == null) { this.attributesToGet = null; return; } this.attributesToGet = new java.util.ArrayList(attributesToGet); } /** *

* This is a legacy parameter. Use ProjectionExpression * instead. For more information, see Legacy Conditional Parameters in the Amazon DynamoDB Developer * Guide. *

*

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

* This is a legacy parameter. Use * ProjectionExpression instead. For more * information, see Legacy Conditional Parameters in the Amazon DynamoDB * Developer Guide. *

* @return A reference to this updated object so that method calls can be * chained together. */ public KeysAndAttributes withAttributesToGet(String... attributesToGet) { if (getAttributesToGet() == null) { this.attributesToGet = new java.util.ArrayList(attributesToGet.length); } for (String value : attributesToGet) { this.attributesToGet.add(value); } return this; } /** *

* This is a legacy parameter. Use ProjectionExpression * instead. For more information, see Legacy Conditional Parameters in the Amazon DynamoDB Developer * Guide. *

*

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

* This is a legacy parameter. Use * ProjectionExpression instead. For more * information, see Legacy Conditional Parameters in the Amazon DynamoDB * Developer Guide. *

* @return A reference to this updated object so that method calls can be * chained together. */ public KeysAndAttributes withAttributesToGet(java.util.Collection attributesToGet) { setAttributesToGet(attributesToGet); 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. *

* * @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; } /** *

* 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; } /** *

* A string that identifies one or more attributes to retrieve from the * table. These attributes can include scalars, sets, or elements of a JSON * document. The attributes in the ProjectionExpression must be * separated by commas. *

*

* If no attribute names are specified, then all attributes will be * returned. If any of the requested attributes are not found, they will not * appear in the result. *

*

* For more information, see Accessing Item Attributes in the Amazon DynamoDB Developer * Guide. *

* * @return

* A string that identifies one or more attributes to retrieve from * the table. These attributes can include scalars, sets, or * elements of a JSON document. The attributes in the * ProjectionExpression must be separated by commas. *

*

* If no attribute names are specified, then all attributes will be * returned. If any of the requested attributes are not found, they * will not appear in the result. *

*

* For more information, see Accessing Item Attributes in the Amazon DynamoDB * Developer Guide. *

*/ public String getProjectionExpression() { return projectionExpression; } /** *

* A string that identifies one or more attributes to retrieve from the * table. These attributes can include scalars, sets, or elements of a JSON * document. The attributes in the ProjectionExpression must be * separated by commas. *

*

* If no attribute names are specified, then all attributes will be * returned. If any of the requested attributes are not found, they will not * appear in the result. *

*

* For more information, see Accessing Item Attributes in the Amazon DynamoDB Developer * Guide. *

* * @param projectionExpression

* A string that identifies one or more attributes to retrieve * from the table. These attributes can include scalars, sets, or * elements of a JSON document. The attributes in the * ProjectionExpression must be separated by commas. *

*

* If no attribute names are specified, then all attributes will * be returned. If any of the requested attributes are not found, * they will not appear in the result. *

*

* For more information, see Accessing Item Attributes in the Amazon DynamoDB * Developer Guide. *

*/ public void setProjectionExpression(String projectionExpression) { this.projectionExpression = projectionExpression; } /** *

* A string that identifies one or more attributes to retrieve from the * table. These attributes can include scalars, sets, or elements of a JSON * document. The attributes in the ProjectionExpression must be * separated by commas. *

*

* If no attribute names are specified, then all attributes will be * returned. If any of the requested attributes are not found, they will not * appear in the result. *

*

* For more information, see Accessing Item Attributes in the Amazon DynamoDB Developer * Guide. *

*

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

* A string that identifies one or more attributes to retrieve * from the table. These attributes can include scalars, sets, or * elements of a JSON document. The attributes in the * ProjectionExpression must be separated by commas. *

*

* If no attribute names are specified, then all attributes will * be returned. If any of the requested attributes are not found, * they will not appear in the result. *

*

* For more information, see Accessing Item Attributes in the Amazon DynamoDB * Developer Guide. *

* @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; } /** *

* One or more substitution tokens for attribute names in an expression. The * following are some use cases for using * ExpressionAttributeNames: *

*
    *
  • *

    * To access an attribute whose name conflicts with a DynamoDB reserved * word. *

    *
  • *
  • *

    * To create a placeholder for repeating occurrences of an attribute name in * an expression. *

    *
  • *
  • *

    * To prevent special characters in an attribute name from being * misinterpreted in an expression. *

    *
  • *
*

* Use the # character in an expression to dereference an attribute * name. For example, consider the following attribute name: *

*
    *
  • *

    * Percentile *

    *
  • *
*

* The name of this attribute conflicts with a reserved word, so it cannot * be used directly in an expression. (For the complete list of reserved * words, see Reserved Words in the Amazon DynamoDB Developer Guide). To * work around this, you could specify the following for * ExpressionAttributeNames: *

*
    *
  • *

    * {"#P":"Percentile"} *

    *
  • *
*

* You could then use this substitution in an expression, as in this * example: *

*
    *
  • *

    * #P = :val *

    *
  • *
* *

* Tokens that begin with the : character are expression attribute * values, which are placeholders for the actual value at runtime. *

*
*

* For more information on expression attribute names, see Accessing Item Attributes in the Amazon DynamoDB Developer * Guide. *

* * @return

* One or more substitution tokens for attribute names in an * expression. The following are some use cases for using * ExpressionAttributeNames: *

*
    *
  • *

    * To access an attribute whose name conflicts with a DynamoDB * reserved word. *

    *
  • *
  • *

    * To create a placeholder for repeating occurrences of an attribute * name in an expression. *

    *
  • *
  • *

    * To prevent special characters in an attribute name from being * misinterpreted in an expression. *

    *
  • *
*

* Use the # character in an expression to dereference an * attribute name. For example, consider the following attribute * name: *

*
    *
  • *

    * Percentile *

    *
  • *
*

* The name of this attribute conflicts with a reserved word, so it * cannot be used directly in an expression. (For the complete list * of reserved words, see Reserved Words in the Amazon DynamoDB Developer * Guide). To work around this, you could specify the following * for ExpressionAttributeNames: *

*
    *
  • *

    * {"#P":"Percentile"} *

    *
  • *
*

* You could then use this substitution in an expression, as in this * example: *

*
    *
  • *

    * #P = :val *

    *
  • *
* *

* Tokens that begin with the : character are expression * attribute values, which are placeholders for the actual value * at runtime. *

*
*

* For more information on expression attribute names, see Accessing Item Attributes in the Amazon DynamoDB * Developer Guide. *

*/ public java.util.Map getExpressionAttributeNames() { return expressionAttributeNames; } /** *

* One or more substitution tokens for attribute names in an expression. The * following are some use cases for using * ExpressionAttributeNames: *

*
    *
  • *

    * To access an attribute whose name conflicts with a DynamoDB reserved * word. *

    *
  • *
  • *

    * To create a placeholder for repeating occurrences of an attribute name in * an expression. *

    *
  • *
  • *

    * To prevent special characters in an attribute name from being * misinterpreted in an expression. *

    *
  • *
*

* Use the # character in an expression to dereference an attribute * name. For example, consider the following attribute name: *

*
    *
  • *

    * Percentile *

    *
  • *
*

* The name of this attribute conflicts with a reserved word, so it cannot * be used directly in an expression. (For the complete list of reserved * words, see Reserved Words in the Amazon DynamoDB Developer Guide). To * work around this, you could specify the following for * ExpressionAttributeNames: *

*
    *
  • *

    * {"#P":"Percentile"} *

    *
  • *
*

* You could then use this substitution in an expression, as in this * example: *

*
    *
  • *

    * #P = :val *

    *
  • *
* *

* Tokens that begin with the : character are expression attribute * values, which are placeholders for the actual value at runtime. *

*
*

* For more information on expression attribute names, see Accessing Item Attributes in the Amazon DynamoDB Developer * Guide. *

* * @param expressionAttributeNames

* One or more substitution tokens for attribute names in an * expression. The following are some use cases for using * ExpressionAttributeNames: *

*
    *
  • *

    * To access an attribute whose name conflicts with a DynamoDB * reserved word. *

    *
  • *
  • *

    * To create a placeholder for repeating occurrences of an * attribute name in an expression. *

    *
  • *
  • *

    * To prevent special characters in an attribute name from being * misinterpreted in an expression. *

    *
  • *
*

* Use the # character in an expression to dereference an * attribute name. For example, consider the following attribute * name: *

*
    *
  • *

    * Percentile *

    *
  • *
*

* The name of this attribute conflicts with a reserved word, so * it cannot be used directly in an expression. (For the complete * list of reserved words, see Reserved Words in the Amazon DynamoDB Developer * Guide). To work around this, you could specify the * following for ExpressionAttributeNames: *

*
    *
  • *

    * {"#P":"Percentile"} *

    *
  • *
*

* You could then use this substitution in an expression, as in * this example: *

*
    *
  • *

    * #P = :val *

    *
  • *
* *

* Tokens that begin with the : character are * expression attribute values, which are placeholders for * the actual value at runtime. *

*
*

* For more information on expression attribute names, see Accessing Item Attributes in the Amazon DynamoDB * Developer Guide. *

*/ public void setExpressionAttributeNames(java.util.Map expressionAttributeNames) { this.expressionAttributeNames = expressionAttributeNames; } /** *

* One or more substitution tokens for attribute names in an expression. The * following are some use cases for using * ExpressionAttributeNames: *

*
    *
  • *

    * To access an attribute whose name conflicts with a DynamoDB reserved * word. *

    *
  • *
  • *

    * To create a placeholder for repeating occurrences of an attribute name in * an expression. *

    *
  • *
  • *

    * To prevent special characters in an attribute name from being * misinterpreted in an expression. *

    *
  • *
*

* Use the # character in an expression to dereference an attribute * name. For example, consider the following attribute name: *

*
    *
  • *

    * Percentile *

    *
  • *
*

* The name of this attribute conflicts with a reserved word, so it cannot * be used directly in an expression. (For the complete list of reserved * words, see Reserved Words in the Amazon DynamoDB Developer Guide). To * work around this, you could specify the following for * ExpressionAttributeNames: *

*
    *
  • *

    * {"#P":"Percentile"} *

    *
  • *
*

* You could then use this substitution in an expression, as in this * example: *

*
    *
  • *

    * #P = :val *

    *
  • *
* *

* Tokens that begin with the : character are expression attribute * values, which are placeholders for the actual value at runtime. *

*
*

* For more information on expression attribute names, see Accessing Item Attributes in the Amazon DynamoDB Developer * Guide. *

*

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

* One or more substitution tokens for attribute names in an * expression. The following are some use cases for using * ExpressionAttributeNames: *

*
    *
  • *

    * To access an attribute whose name conflicts with a DynamoDB * reserved word. *

    *
  • *
  • *

    * To create a placeholder for repeating occurrences of an * attribute name in an expression. *

    *
  • *
  • *

    * To prevent special characters in an attribute name from being * misinterpreted in an expression. *

    *
  • *
*

* Use the # character in an expression to dereference an * attribute name. For example, consider the following attribute * name: *

*
    *
  • *

    * Percentile *

    *
  • *
*

* The name of this attribute conflicts with a reserved word, so * it cannot be used directly in an expression. (For the complete * list of reserved words, see Reserved Words in the Amazon DynamoDB Developer * Guide). To work around this, you could specify the * following for ExpressionAttributeNames: *

*
    *
  • *

    * {"#P":"Percentile"} *

    *
  • *
*

* You could then use this substitution in an expression, as in * this example: *

*
    *
  • *

    * #P = :val *

    *
  • *
* *

* Tokens that begin with the : character are * expression attribute values, which are placeholders for * the actual value at runtime. *

*
*

* For more information on expression attribute names, see Accessing Item Attributes in the Amazon DynamoDB * Developer Guide. *

* @return A reference to this updated object so that method calls can be * chained together. */ public KeysAndAttributes withExpressionAttributeNames( java.util.Map expressionAttributeNames) { this.expressionAttributeNames = expressionAttributeNames; return this; } /** *

* One or more substitution tokens for attribute names in an expression. The * following are some use cases for using * ExpressionAttributeNames: *

*
    *
  • *

    * To access an attribute whose name conflicts with a DynamoDB reserved * word. *

    *
  • *
  • *

    * To create a placeholder for repeating occurrences of an attribute name in * an expression. *

    *
  • *
  • *

    * To prevent special characters in an attribute name from being * misinterpreted in an expression. *

    *
  • *
*

* Use the # character in an expression to dereference an attribute * name. For example, consider the following attribute name: *

*
    *
  • *

    * Percentile *

    *
  • *
*

* The name of this attribute conflicts with a reserved word, so it cannot * be used directly in an expression. (For the complete list of reserved * words, see Reserved Words in the Amazon DynamoDB Developer Guide). To * work around this, you could specify the following for * ExpressionAttributeNames: *

*
    *
  • *

    * {"#P":"Percentile"} *

    *
  • *
*

* You could then use this substitution in an expression, as in this * example: *

*
    *
  • *

    * #P = :val *

    *
  • *
* *

* Tokens that begin with the : character are expression attribute * values, which are placeholders for the actual value at runtime. *

*
*

* For more information on expression attribute names, see Accessing Item Attributes in the Amazon DynamoDB Developer * Guide. *

*

* 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. * @return A reference to this updated object so that method calls can be * chained together. */ 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 (getConsistentRead() != null) sb.append("ConsistentRead: " + getConsistentRead() + ","); 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 + ((getConsistentRead() == null) ? 0 : getConsistentRead().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.getConsistentRead() == null ^ this.getConsistentRead() == null) return false; if (other.getConsistentRead() != null && other.getConsistentRead().equals(this.getConsistentRead()) == 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; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy