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

software.amazon.awssdk.services.dynamodb.model.KeysAndAttributes Maven / Gradle / Ivy

Go to download

A single bundled dependency that includes all service and dependent JARs with third-party libraries relocated to different namespaces.

There is a newer version: 2.5.20
Show newest version
/*
 * Copyright 2013-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 software.amazon.awssdk.services.dynamodb.model;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.protocol.ProtocolMarshaller;
import software.amazon.awssdk.core.protocol.StructuredPojo;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.services.dynamodb.transform.KeysAndAttributesMarshaller;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

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

*/ @Generated("software.amazon.awssdk:codegen") public final class KeysAndAttributes implements StructuredPojo, ToCopyableBuilder { private final List> keys; private final List attributesToGet; private final Boolean consistentRead; private final String projectionExpression; private final Map expressionAttributeNames; private KeysAndAttributes(BuilderImpl builder) { this.keys = builder.keys; this.attributesToGet = builder.attributesToGet; this.consistentRead = builder.consistentRead; this.projectionExpression = builder.projectionExpression; this.expressionAttributeNames = builder.expressionAttributeNames; } /** *

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

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

* * @return The primary key attribute values that define the items and the attributes associated with the items. */ public List> keys() { return keys; } /** *

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

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

* * @return This is a legacy parameter. Use ProjectionExpression instead. For more information, see * Legacy Conditional Parameters in the Amazon DynamoDB Developer Guide. */ public List attributesToGet() { return 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. *

* * @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 consistentRead() { return 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. *

* * @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 projectionExpression() { return 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. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

* * @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 Map expressionAttributeNames() { return expressionAttributeNames; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(keys()); hashCode = 31 * hashCode + Objects.hashCode(attributesToGet()); hashCode = 31 * hashCode + Objects.hashCode(consistentRead()); hashCode = 31 * hashCode + Objects.hashCode(projectionExpression()); hashCode = 31 * hashCode + Objects.hashCode(expressionAttributeNames()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof KeysAndAttributes)) { return false; } KeysAndAttributes other = (KeysAndAttributes) obj; return Objects.equals(keys(), other.keys()) && Objects.equals(attributesToGet(), other.attributesToGet()) && Objects.equals(consistentRead(), other.consistentRead()) && Objects.equals(projectionExpression(), other.projectionExpression()) && Objects.equals(expressionAttributeNames(), other.expressionAttributeNames()); } @Override public String toString() { return ToString.builder("KeysAndAttributes").add("Keys", keys()).add("AttributesToGet", attributesToGet()) .add("ConsistentRead", consistentRead()).add("ProjectionExpression", projectionExpression()) .add("ExpressionAttributeNames", expressionAttributeNames()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Keys": return Optional.ofNullable(clazz.cast(keys())); case "AttributesToGet": return Optional.ofNullable(clazz.cast(attributesToGet())); case "ConsistentRead": return Optional.ofNullable(clazz.cast(consistentRead())); case "ProjectionExpression": return Optional.ofNullable(clazz.cast(projectionExpression())); case "ExpressionAttributeNames": return Optional.ofNullable(clazz.cast(expressionAttributeNames())); default: return Optional.empty(); } } @SdkInternalApi @Override public void marshall(ProtocolMarshaller protocolMarshaller) { KeysAndAttributesMarshaller.getInstance().marshall(this, protocolMarshaller); } public interface Builder extends CopyableBuilder { /** *

* 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. * @return Returns a reference to this object so that method calls can be chained together. */ Builder keys(Collection> 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. * @return Returns a reference to this object so that method calls can be chained together. */ Builder keys(Map... keys); /** *

* 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. * @return Returns a reference to this object so that method calls can be chained together. */ Builder attributesToGet(Collection 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. * @return Returns a reference to this object so that method calls can be chained together. */ Builder attributesToGet(String... 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. *

* * @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 Returns a reference to this object so that method calls can be chained together. */ Builder consistentRead(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. *

* * @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 Returns a reference to this object so that method calls can be chained together. */ Builder projectionExpression(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. *

* * @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 Returns a reference to this object so that method calls can be chained together. */ Builder expressionAttributeNames(Map expressionAttributeNames); } static final class BuilderImpl implements Builder { private List> keys = DefaultSdkAutoConstructList.getInstance(); private List attributesToGet = DefaultSdkAutoConstructList.getInstance(); private Boolean consistentRead; private String projectionExpression; private Map expressionAttributeNames = DefaultSdkAutoConstructMap.getInstance(); private BuilderImpl() { } private BuilderImpl(KeysAndAttributes model) { keys(model.keys); attributesToGet(model.attributesToGet); consistentRead(model.consistentRead); projectionExpression(model.projectionExpression); expressionAttributeNames(model.expressionAttributeNames); } public final Collection> getKeys() { return keys; } @Override public final Builder keys(Collection> keys) { this.keys = KeyListCopier.copy(keys); return this; } @Override @SafeVarargs public final Builder keys(Map... keys) { keys(Arrays.asList(keys)); return this; } public final void setKeys(Collection> keys) { this.keys = KeyListCopier.copy(keys); } public final Collection getAttributesToGet() { return attributesToGet; } @Override public final Builder attributesToGet(Collection attributesToGet) { this.attributesToGet = AttributeNameListCopier.copy(attributesToGet); return this; } @Override @SafeVarargs public final Builder attributesToGet(String... attributesToGet) { attributesToGet(Arrays.asList(attributesToGet)); return this; } public final void setAttributesToGet(Collection attributesToGet) { this.attributesToGet = AttributeNameListCopier.copy(attributesToGet); } public final Boolean getConsistentRead() { return consistentRead; } @Override public final Builder consistentRead(Boolean consistentRead) { this.consistentRead = consistentRead; return this; } public final void setConsistentRead(Boolean consistentRead) { this.consistentRead = consistentRead; } public final String getProjectionExpression() { return projectionExpression; } @Override public final Builder projectionExpression(String projectionExpression) { this.projectionExpression = projectionExpression; return this; } public final void setProjectionExpression(String projectionExpression) { this.projectionExpression = projectionExpression; } public final Map getExpressionAttributeNames() { return expressionAttributeNames; } @Override public final Builder expressionAttributeNames(Map expressionAttributeNames) { this.expressionAttributeNames = ExpressionAttributeNameMapCopier.copy(expressionAttributeNames); return this; } public final void setExpressionAttributeNames(Map expressionAttributeNames) { this.expressionAttributeNames = ExpressionAttributeNameMapCopier.copy(expressionAttributeNames); } @Override public KeysAndAttributes build() { return new KeysAndAttributes(this); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy