expressionAttributeNames;
private GetItemRequest(BuilderImpl builder) {
super(builder);
this.tableName = builder.tableName;
this.key = builder.key;
this.attributesToGet = builder.attributesToGet;
this.consistentRead = builder.consistentRead;
this.returnConsumedCapacity = builder.returnConsumedCapacity;
this.projectionExpression = builder.projectionExpression;
this.expressionAttributeNames = builder.expressionAttributeNames;
}
/**
*
* The name of the table containing the requested item.
*
*
* @return The name of the table containing the requested item.
*/
public String tableName() {
return tableName;
}
/**
* Returns true if the Key property was specified by the sender (it may be empty), or false if the sender did not
* specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public boolean hasKey() {
return key != null && !(key instanceof SdkAutoConstructMap);
}
/**
*
* A map of attribute names to AttributeValue
objects, representing the primary key of the item to
* retrieve.
*
*
* For the primary key, you must provide all of the attributes. For example, with a simple primary key, you only
* need to provide a value for the partition key. For a composite primary key, you must provide values for both the
* partition key and the sort key.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasKey()} to see if a value was sent in this field.
*
*
* @return A map of attribute names to AttributeValue
objects, representing the primary key of the item
* to retrieve.
*
* For the primary key, you must provide all of the attributes. For example, with a simple primary key, you
* only need to provide a value for the partition key. For a composite primary key, you must provide values
* for both the partition key and the sort key.
*/
public Map key() {
return key;
}
/**
* Returns true if the AttributesToGet property was specified by the sender (it may be empty), or false if the
* sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS
* service.
*/
public boolean hasAttributesToGet() {
return attributesToGet != null && !(attributesToGet instanceof SdkAutoConstructList);
}
/**
*
* This is a legacy parameter. Use ProjectionExpression
instead. For more information, see AttributesToGet in the Amazon DynamoDB Developer Guide .
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasAttributesToGet()} to see if a value was sent in this field.
*
*
* @return This is a legacy parameter. Use ProjectionExpression
instead. For more information, see AttributesToGet in the Amazon DynamoDB Developer Guide .
*/
public List attributesToGet() {
return attributesToGet;
}
/**
*
* Determines the read consistency model: If set to true
, then the operation uses strongly consistent
* reads; otherwise, the operation uses eventually consistent reads.
*
*
* @return Determines the read consistency model: If set to true
, then the operation uses strongly
* consistent reads; otherwise, the operation uses eventually consistent reads.
*/
public Boolean consistentRead() {
return consistentRead;
}
/**
* Returns the value of the ReturnConsumedCapacity property for this object.
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #returnConsumedCapacity} will return {@link ReturnConsumedCapacity#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #returnConsumedCapacityAsString}.
*
*
* @return The value of the ReturnConsumedCapacity property for this object.
* @see ReturnConsumedCapacity
*/
public ReturnConsumedCapacity returnConsumedCapacity() {
return ReturnConsumedCapacity.fromValue(returnConsumedCapacity);
}
/**
* Returns the value of the ReturnConsumedCapacity property for this object.
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #returnConsumedCapacity} will return {@link ReturnConsumedCapacity#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #returnConsumedCapacityAsString}.
*
*
* @return The value of the ReturnConsumedCapacity property for this object.
* @see ReturnConsumedCapacity
*/
public String returnConsumedCapacityAsString() {
return returnConsumedCapacity;
}
/**
*
* 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 expression must be separated by commas.
*
*
* If no attribute names are specified, then all attributes are returned. If any of the requested attributes are not
* found, they do not appear in the result.
*
*
* For more information, see Specifying 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 expression must be separated by
* commas.
*
* If no attribute names are specified, then all attributes are returned. If any of the requested attributes
* are not found, they do not appear in the result.
*
*
* For more information, see Specifying Item Attributes in the Amazon DynamoDB Developer Guide .
*/
public String projectionExpression() {
return projectionExpression;
}
/**
* Returns true if the ExpressionAttributeNames property was specified by the sender (it may be empty), or false if
* the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS
* service.
*/
public boolean hasExpressionAttributeNames() {
return expressionAttributeNames != null && !(expressionAttributeNames instanceof SdkAutoConstructMap);
}
/**
*
* 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:
*
*
*
* 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:
*
*
*
*
* 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 Specifying Item Attributes in the Amazon DynamoDB Developer Guide .
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasExpressionAttributeNames()} to see if a value was sent in this field.
*
*
* @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:
*
*
*
* 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:
*
*
*
*
* 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 Specifying 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 extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(tableName());
hashCode = 31 * hashCode + Objects.hashCode(key());
hashCode = 31 * hashCode + Objects.hashCode(attributesToGet());
hashCode = 31 * hashCode + Objects.hashCode(consistentRead());
hashCode = 31 * hashCode + Objects.hashCode(returnConsumedCapacityAsString());
hashCode = 31 * hashCode + Objects.hashCode(projectionExpression());
hashCode = 31 * hashCode + Objects.hashCode(expressionAttributeNames());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GetItemRequest)) {
return false;
}
GetItemRequest other = (GetItemRequest) obj;
return Objects.equals(tableName(), other.tableName()) && Objects.equals(key(), other.key())
&& Objects.equals(attributesToGet(), other.attributesToGet())
&& Objects.equals(consistentRead(), other.consistentRead())
&& Objects.equals(returnConsumedCapacityAsString(), other.returnConsumedCapacityAsString())
&& Objects.equals(projectionExpression(), other.projectionExpression())
&& Objects.equals(expressionAttributeNames(), other.expressionAttributeNames());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public String toString() {
return ToString.builder("GetItemRequest").add("TableName", tableName()).add("Key", key())
.add("AttributesToGet", attributesToGet()).add("ConsistentRead", consistentRead())
.add("ReturnConsumedCapacity", returnConsumedCapacityAsString())
.add("ProjectionExpression", projectionExpression()).add("ExpressionAttributeNames", expressionAttributeNames())
.build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "TableName":
return Optional.ofNullable(clazz.cast(tableName()));
case "Key":
return Optional.ofNullable(clazz.cast(key()));
case "AttributesToGet":
return Optional.ofNullable(clazz.cast(attributesToGet()));
case "ConsistentRead":
return Optional.ofNullable(clazz.cast(consistentRead()));
case "ReturnConsumedCapacity":
return Optional.ofNullable(clazz.cast(returnConsumedCapacityAsString()));
case "ProjectionExpression":
return Optional.ofNullable(clazz.cast(projectionExpression()));
case "ExpressionAttributeNames":
return Optional.ofNullable(clazz.cast(expressionAttributeNames()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((GetItemRequest) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends DynamoDbRequest.Builder, SdkPojo, CopyableBuilder {
/**
*
* The name of the table containing the requested item.
*
*
* @param tableName
* The name of the table containing the requested item.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder tableName(String tableName);
/**
*
* A map of attribute names to AttributeValue
objects, representing the primary key of the item to
* retrieve.
*
*
* For the primary key, you must provide all of the attributes. For example, with a simple primary key, you only
* need to provide a value for the partition key. For a composite primary key, you must provide values for both
* the partition key and the sort key.
*
*
* @param key
* A map of attribute names to AttributeValue
objects, representing the primary key of the
* item to retrieve.
*
* For the primary key, you must provide all of the attributes. For example, with a simple primary key,
* you only need to provide a value for the partition key. For a composite primary key, you must provide
* values for both the partition key and the sort key.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder key(Map key);
/**
*
* This is a legacy parameter. Use ProjectionExpression
instead. For more information, see AttributesToGet in the Amazon DynamoDB Developer Guide .
*
*
* @param attributesToGet
* This is a legacy parameter. Use ProjectionExpression
instead. For more information, see
* AttributesToGet 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 AttributesToGet in the Amazon DynamoDB Developer Guide .
*
*
* @param attributesToGet
* This is a legacy parameter. Use ProjectionExpression
instead. For more information, see
* AttributesToGet 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);
/**
*
* Determines the read consistency model: If set to true
, then the operation uses strongly
* consistent reads; otherwise, the operation uses eventually consistent reads.
*
*
* @param consistentRead
* Determines the read consistency model: If set to true
, then the operation uses strongly
* consistent reads; otherwise, the operation uses eventually consistent reads.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder consistentRead(Boolean consistentRead);
/**
* Sets the value of the ReturnConsumedCapacity property for this object.
*
* @param returnConsumedCapacity
* The new value for the ReturnConsumedCapacity property for this object.
* @see ReturnConsumedCapacity
* @return Returns a reference to this object so that method calls can be chained together.
* @see ReturnConsumedCapacity
*/
Builder returnConsumedCapacity(String returnConsumedCapacity);
/**
* Sets the value of the ReturnConsumedCapacity property for this object.
*
* @param returnConsumedCapacity
* The new value for the ReturnConsumedCapacity property for this object.
* @see ReturnConsumedCapacity
* @return Returns a reference to this object so that method calls can be chained together.
* @see ReturnConsumedCapacity
*/
Builder returnConsumedCapacity(ReturnConsumedCapacity returnConsumedCapacity);
/**
*
* 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 expression must be separated by commas.
*
*
* If no attribute names are specified, then all attributes are returned. If any of the requested attributes are
* not found, they do not appear in the result.
*
*
* For more information, see Specifying 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 expression must be
* separated by commas.
*
* If no attribute names are specified, then all attributes are returned. If any of the requested
* attributes are not found, they do not appear in the result.
*
*
* For more information, see Specifying 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:
*
*
*
* 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:
*
*
*
*
* 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 Specifying 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:
*
*
*
* 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:
*
*
*
*
* 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 Specifying 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);
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends DynamoDbRequest.BuilderImpl implements Builder {
private String tableName;
private Map key = DefaultSdkAutoConstructMap.getInstance();
private List attributesToGet = DefaultSdkAutoConstructList.getInstance();
private Boolean consistentRead;
private String returnConsumedCapacity;
private String projectionExpression;
private Map expressionAttributeNames = DefaultSdkAutoConstructMap.getInstance();
private BuilderImpl() {
}
private BuilderImpl(GetItemRequest model) {
super(model);
tableName(model.tableName);
key(model.key);
attributesToGet(model.attributesToGet);
consistentRead(model.consistentRead);
returnConsumedCapacity(model.returnConsumedCapacity);
projectionExpression(model.projectionExpression);
expressionAttributeNames(model.expressionAttributeNames);
}
public final String getTableName() {
return tableName;
}
@Override
public final Builder tableName(String tableName) {
this.tableName = tableName;
return this;
}
public final void setTableName(String tableName) {
this.tableName = tableName;
}
public final Map getKey() {
return key != null ? CollectionUtils.mapValues(key, AttributeValue::toBuilder) : null;
}
@Override
public final Builder key(Map key) {
this.key = KeyCopier.copy(key);
return this;
}
public final void setKey(Map key) {
this.key = KeyCopier.copyFromBuilder(key);
}
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 getReturnConsumedCapacityAsString() {
return returnConsumedCapacity;
}
@Override
public final Builder returnConsumedCapacity(String returnConsumedCapacity) {
this.returnConsumedCapacity = returnConsumedCapacity;
return this;
}
@Override
public final Builder returnConsumedCapacity(ReturnConsumedCapacity returnConsumedCapacity) {
this.returnConsumedCapacity(returnConsumedCapacity == null ? null : returnConsumedCapacity.toString());
return this;
}
public final void setReturnConsumedCapacity(String returnConsumedCapacity) {
this.returnConsumedCapacity = returnConsumedCapacity;
}
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 Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public GetItemRequest build() {
return new GetItemRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}