Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * 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;
 

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 hash type primary key, you only need to provide the hash attribute. For a hash-and-range type primary key, you must provide both the hash attribute and the range attribute.

 
 public class KeysAndAttributes implements SerializableCloneable {

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

Constraints:
Length: 1 - 100

 
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 -

 
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. <note>

ProjectionExpression replaces the legacy AttributesToGet parameter.</note>

 
     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

<note>

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

For more information on expression attribute names, see Using Placeholders for Attribute Names and Values in the Amazon DynamoDB Developer Guide.

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

Constraints:
Length: 1 - 100

Returns:
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.

Constraints:
Length: 1 - 100

Parameters:
keys The primary key attribute values that define the items and the attributes associated with the items.
    public void setKeys(java.util.Collection<java.util.Map<String,AttributeValue>> keys) {
        if (keys == null) {
            this. = null;
            return;
        }
        keysCopy.addAll(keys);
        this. = keysCopy;
    }
    
    
The primary key attribute values that define the items and the attributes associated with the items.

NOTE: This method appends the values to the existing list (if any). Use setKeys(java.util.Collection) or withKeys(java.util.Collection) if you want to override the existing values.

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

Constraints:
Length: 1 - 100

Parameters:
keys The primary key attribute values that define the items and the attributes associated with the items.
Returns:
A reference to this updated object so that method calls can be chained together.
        if (getKeys() == nullsetKeys(new java.util.ArrayList<java.util.Map<String,AttributeValue>>(keys.length));
        for (java.util.Map<String,AttributeValuevalue : 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

Parameters:
keys The primary key attribute values that define the items and the attributes associated with the items.
Returns:
A reference to this updated object so that method calls can be chained together.
        if (keys == null) {
            this. = null;
        } else {
            keysCopy.addAll(keys);
            this. = 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 -

Returns:
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<StringgetAttributesToGet() {
        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.

Constraints:
Length: 1 -

Parameters:
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<StringattributesToGet) {
        if (attributesToGet == null) {
            this. = null;
            return;
        }
        com.amazonaws.internal.ListWithAutoConstructFlag<StringattributesToGetCopy = new com.amazonaws.internal.ListWithAutoConstructFlag<String>(attributesToGet.size());
        attributesToGetCopy.addAll(attributesToGet);
        this. = 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.

NOTE: This method appends the values to the existing list (if any). Use setAttributesToGet(java.util.Collection) or withAttributesToGet(java.util.Collection) if you want to override the existing values.

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

Constraints:
Length: 1 -

Parameters:
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.
Returns:
A reference to this updated object so that method calls can be chained together.
    public KeysAndAttributes withAttributesToGet(String... attributesToGet) {
        if (getAttributesToGet() == nullsetAttributesToGet(new java.util.ArrayList<String>(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 -

Parameters:
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.
Returns:
A reference to this updated object so that method calls can be chained together.
    public KeysAndAttributes withAttributesToGet(java.util.Collection<StringattributesToGet) {
        if (attributesToGet == null) {
            this. = null;
        } else {
            com.amazonaws.internal.ListWithAutoConstructFlag<StringattributesToGetCopy = new com.amazonaws.internal.ListWithAutoConstructFlag<String>(attributesToGet.size());
            attributesToGetCopy.addAll(attributesToGet);
            this. = 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.

Returns:
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 ;
    }
    
    
The consistency of a read operation. If set to true, then a strongly consistent read is used; otherwise, an eventually consistent read is used.

Parameters:
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;
    }
    
    
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.

Parameters:
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 updated object so that method calls can be chained together.
    public KeysAndAttributes withConsistentRead(Boolean consistentRead) {
        this. = 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.

Returns:
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 ;
    }

    
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. <note>

ProjectionExpression replaces the legacy AttributesToGet parameter.</note>

Returns:
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. <note>

ProjectionExpression replaces the legacy AttributesToGet parameter.</note>

    public String getProjectionExpression() {
        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. <note>

ProjectionExpression replaces the legacy AttributesToGet parameter.</note>

Parameters:
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. <note>

ProjectionExpression replaces the legacy AttributesToGet parameter.</note>

    public void setProjectionExpression(String projectionExpression) {
        this. = 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. <note>

ProjectionExpression replaces the legacy AttributesToGet parameter.</note>

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

Parameters:
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. <note>

ProjectionExpression replaces the legacy AttributesToGet parameter.</note>

Returns:
A reference to this updated object so that method calls can be chained together.
    public KeysAndAttributes withProjectionExpression(String projectionExpression) {
        this. = 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

<note>

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

For more information on expression attribute names, see Using Placeholders for Attribute Names and Values in the Amazon DynamoDB Developer Guide.

Returns:
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

<note>

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

For more information on expression attribute names, see Using Placeholders for Attribute Names and Values 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

<note>

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

For more information on expression attribute names, see Using Placeholders for Attribute Names and Values in the Amazon DynamoDB Developer Guide.

Parameters:
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

<note>

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

For more information on expression attribute names, see Using Placeholders for Attribute Names and Values in the Amazon DynamoDB Developer Guide.

    public void setExpressionAttributeNames(java.util.Map<String,StringexpressionAttributeNames) {
        this. = 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

<note>

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

For more information on expression attribute names, see Using Placeholders for Attribute Names and Values in the Amazon DynamoDB Developer Guide.

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

Parameters:
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

<note>

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

For more information on expression attribute names, see Using Placeholders for Attribute Names and Values in the Amazon DynamoDB Developer Guide.

Returns:
A reference to this updated object so that method calls can be chained together.
    public KeysAndAttributes withExpressionAttributeNames(java.util.Map<String,StringexpressionAttributeNames) {
        setExpressionAttributeNames(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

<note>

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

For more information on expression attribute names, see Using Placeholders for Attribute Names and Values 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.

Parameters:
key The key of the entry to be added into ExpressionAttributeNames.
value The corresponding value of the entry to be added into ExpressionAttributeNames.
    if (null == this.) {
    }
      throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
    this..put(keyvalue);
    return this;
  }

  
Removes all the entries added into ExpressionAttributeNames.

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

    this. = null;
    return this;
  }
  
    
Returns a string representation of this object; useful for testing and debugging.

Returns:
A string representation of this object.
See also:
java.lang.Object.toString()
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getKeys() != nullsb.append("Keys: " + getKeys() + ",");
        if (getAttributesToGet() != nullsb.append("AttributesToGet: " + getAttributesToGet() + ",");
        if (isConsistentRead() != nullsb.append("ConsistentRead: " + isConsistentRead() + ",");
        if (getProjectionExpression() != nullsb.append("ProjectionExpression: " + getProjectionExpression() + ",");
        if (getExpressionAttributeNames() != nullsb.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 == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof KeysAndAttributes == falsereturn false;
        KeysAndAttributes other = (KeysAndAttributes)obj;
        
        if (other.getKeys() == null ^ this.getKeys() == nullreturn false;
        if (other.getKeys() != null && other.getKeys().equals(this.getKeys()) == falsereturn false
        if (other.getAttributesToGet() == null ^ this.getAttributesToGet() == nullreturn false;
        if (other.getAttributesToGet() != null && other.getAttributesToGet().equals(this.getAttributesToGet()) == falsereturn false
        if (other.isConsistentRead() == null ^ this.isConsistentRead() == nullreturn false;
        if (other.isConsistentRead() != null && other.isConsistentRead().equals(this.isConsistentRead()) == falsereturn false
        if (other.getProjectionExpression() == null ^ this.getProjectionExpression() == nullreturn false;
        if (other.getProjectionExpression() != null && other.getProjectionExpression().equals(this.getProjectionExpression()) == falsereturn false
        if (other.getExpressionAttributeNames() == null ^ this.getExpressionAttributeNames() == nullreturn false;
        if (other.getExpressionAttributeNames() != null && other.getExpressionAttributeNames().equals(this.getExpressionAttributeNames()) == falsereturn false
        return true;
    }
    
    @Override
    public KeysAndAttributes clone() {
        try {
            return (KeysAndAttributessuper.clone();
        
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException(
                    "Got a CloneNotSupportedException from Object.clone() "
                    + "even though we're Cloneable!",
                    e);
        }
        
    }
}
    
New to GrepCode? Check out our FAQ X