
software.amazon.awssdk.services.dynamodb.model.DeleteItemResponse Maven / Gradle / Ivy
/*
* 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.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents the output of a DeleteItem
operation.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class DeleteItemResponse extends DynamoDbResponse implements
ToCopyableBuilder {
private final Map attributes;
private final ConsumedCapacity consumedCapacity;
private final ItemCollectionMetrics itemCollectionMetrics;
private DeleteItemResponse(BuilderImpl builder) {
super(builder);
this.attributes = builder.attributes;
this.consumedCapacity = builder.consumedCapacity;
this.itemCollectionMetrics = builder.itemCollectionMetrics;
}
/**
*
* A map of attribute names to AttributeValue
objects, representing the item as it appeared before the
* DeleteItem
operation. This map appears in the response only if ReturnValues
was
* specified as ALL_OLD
in the request.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return A map of attribute names to AttributeValue
objects, representing the item as it appeared
* before the DeleteItem
operation. This map appears in the response only if
* ReturnValues
was specified as ALL_OLD
in the request.
*/
public Map attributes() {
return attributes;
}
/**
*
* The capacity units consumed by the DeleteItem
operation. The data returned includes the total
* provisioned throughput consumed, along with statistics for the table and any indexes involved in the operation.
* ConsumedCapacity
is only returned if the ReturnConsumedCapacity
parameter was
* specified. For more information, see Provisioned Throughput in the Amazon DynamoDB Developer Guide.
*
*
* @return The capacity units consumed by the DeleteItem
operation. The data returned includes the
* total provisioned throughput consumed, along with statistics for the table and any indexes involved in
* the operation. ConsumedCapacity
is only returned if the ReturnConsumedCapacity
* parameter was specified. For more information, see Provisioned Throughput in the Amazon DynamoDB Developer Guide.
*/
public ConsumedCapacity consumedCapacity() {
return consumedCapacity;
}
/**
*
* Information about item collections, if any, that were affected by the DeleteItem
operation.
* ItemCollectionMetrics
is only returned if the ReturnItemCollectionMetrics
parameter was
* specified. If the table does not have any local secondary indexes, this information is not returned in the
* response.
*
*
* Each ItemCollectionMetrics
element consists of:
*
*
* -
*
* ItemCollectionKey
- The partition key value of the item collection. This is the same as the
* partition key value of the item itself.
*
*
* -
*
* SizeEstimateRangeGB
- An estimate of item collection size, in gigabytes. This value is a two-element
* array containing a lower bound and an upper bound for the estimate. The estimate includes the size of all the
* items in the table, plus the size of all attributes projected into all of the local secondary indexes on that
* table. Use this estimate to measure whether a local secondary index is approaching its size limit.
*
*
* The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the estimate.
*
*
*
*
* @return Information about item collections, if any, that were affected by the DeleteItem
operation.
* ItemCollectionMetrics
is only returned if the ReturnItemCollectionMetrics
* parameter was specified. If the table does not have any local secondary indexes, this information is not
* returned in the response.
*
* Each ItemCollectionMetrics
element consists of:
*
*
* -
*
* ItemCollectionKey
- The partition key value of the item collection. This is the same as the
* partition key value of the item itself.
*
*
* -
*
* SizeEstimateRangeGB
- An estimate of item collection size, in gigabytes. This value is a
* two-element array containing a lower bound and an upper bound for the estimate. The estimate includes the
* size of all the items in the table, plus the size of all attributes projected into all of the local
* secondary indexes on that table. Use this estimate to measure whether a local secondary index is
* approaching its size limit.
*
*
* The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the
* estimate.
*
*
*/
public ItemCollectionMetrics itemCollectionMetrics() {
return itemCollectionMetrics;
}
@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 + Objects.hashCode(attributes());
hashCode = 31 * hashCode + Objects.hashCode(consumedCapacity());
hashCode = 31 * hashCode + Objects.hashCode(itemCollectionMetrics());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof DeleteItemResponse)) {
return false;
}
DeleteItemResponse other = (DeleteItemResponse) obj;
return Objects.equals(attributes(), other.attributes()) && Objects.equals(consumedCapacity(), other.consumedCapacity())
&& Objects.equals(itemCollectionMetrics(), other.itemCollectionMetrics());
}
@Override
public String toString() {
return ToString.builder("DeleteItemResponse").add("Attributes", attributes()).add("ConsumedCapacity", consumedCapacity())
.add("ItemCollectionMetrics", itemCollectionMetrics()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Attributes":
return Optional.ofNullable(clazz.cast(attributes()));
case "ConsumedCapacity":
return Optional.ofNullable(clazz.cast(consumedCapacity()));
case "ItemCollectionMetrics":
return Optional.ofNullable(clazz.cast(itemCollectionMetrics()));
default:
return Optional.empty();
}
}
public interface Builder extends DynamoDbResponse.Builder, CopyableBuilder {
/**
*
* A map of attribute names to AttributeValue
objects, representing the item as it appeared before
* the DeleteItem
operation. This map appears in the response only if ReturnValues
was
* specified as ALL_OLD
in the request.
*
*
* @param attributes
* A map of attribute names to AttributeValue
objects, representing the item as it appeared
* before the DeleteItem
operation. This map appears in the response only if
* ReturnValues
was specified as ALL_OLD
in the request.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder attributes(Map attributes);
/**
*
* The capacity units consumed by the DeleteItem
operation. The data returned includes the total
* provisioned throughput consumed, along with statistics for the table and any indexes involved in the
* operation. ConsumedCapacity
is only returned if the ReturnConsumedCapacity
* parameter was specified. For more information, see Provisioned Throughput in the Amazon DynamoDB Developer Guide.
*
*
* @param consumedCapacity
* The capacity units consumed by the DeleteItem
operation. The data returned includes the
* total provisioned throughput consumed, along with statistics for the table and any indexes involved in
* the operation. ConsumedCapacity
is only returned if the
* ReturnConsumedCapacity
parameter was specified. For more information, see Provisioned Throughput in the Amazon DynamoDB Developer Guide.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder consumedCapacity(ConsumedCapacity consumedCapacity);
/**
*
* The capacity units consumed by the DeleteItem
operation. The data returned includes the total
* provisioned throughput consumed, along with statistics for the table and any indexes involved in the
* operation. ConsumedCapacity
is only returned if the ReturnConsumedCapacity
* parameter was specified. For more information, see Provisioned Throughput in the Amazon DynamoDB Developer Guide.
*
* This is a convenience that creates an instance of the {@link ConsumedCapacity.Builder} avoiding the need to
* create one manually via {@link ConsumedCapacity#builder()}.
*
* When the {@link Consumer} completes, {@link ConsumedCapacity.Builder#build()} is called immediately and its
* result is passed to {@link #consumedCapacity(ConsumedCapacity)}.
*
* @param consumedCapacity
* a consumer that will call methods on {@link ConsumedCapacity.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #consumedCapacity(ConsumedCapacity)
*/
default Builder consumedCapacity(Consumer consumedCapacity) {
return consumedCapacity(ConsumedCapacity.builder().applyMutation(consumedCapacity).build());
}
/**
*
* Information about item collections, if any, that were affected by the DeleteItem
operation.
* ItemCollectionMetrics
is only returned if the ReturnItemCollectionMetrics
parameter
* was specified. If the table does not have any local secondary indexes, this information is not returned in
* the response.
*
*
* Each ItemCollectionMetrics
element consists of:
*
*
* -
*
* ItemCollectionKey
- The partition key value of the item collection. This is the same as the
* partition key value of the item itself.
*
*
* -
*
* SizeEstimateRangeGB
- An estimate of item collection size, in gigabytes. This value is a
* two-element array containing a lower bound and an upper bound for the estimate. The estimate includes the
* size of all the items in the table, plus the size of all attributes projected into all of the local secondary
* indexes on that table. Use this estimate to measure whether a local secondary index is approaching its size
* limit.
*
*
* The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the
* estimate.
*
*
*
*
* @param itemCollectionMetrics
* Information about item collections, if any, that were affected by the DeleteItem
* operation. ItemCollectionMetrics
is only returned if the
* ReturnItemCollectionMetrics
parameter was specified. If the table does not have any local
* secondary indexes, this information is not returned in the response.
*
* Each ItemCollectionMetrics
element consists of:
*
*
* -
*
* ItemCollectionKey
- The partition key value of the item collection. This is the same as
* the partition key value of the item itself.
*
*
* -
*
* SizeEstimateRangeGB
- An estimate of item collection size, in gigabytes. This value is a
* two-element array containing a lower bound and an upper bound for the estimate. The estimate includes
* the size of all the items in the table, plus the size of all attributes projected into all of the
* local secondary indexes on that table. Use this estimate to measure whether a local secondary index is
* approaching its size limit.
*
*
* The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of
* the estimate.
*
*
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder itemCollectionMetrics(ItemCollectionMetrics itemCollectionMetrics);
/**
*
* Information about item collections, if any, that were affected by the DeleteItem
operation.
* ItemCollectionMetrics
is only returned if the ReturnItemCollectionMetrics
parameter
* was specified. If the table does not have any local secondary indexes, this information is not returned in
* the response.
*
*
* Each ItemCollectionMetrics
element consists of:
*
*
* -
*
* ItemCollectionKey
- The partition key value of the item collection. This is the same as the
* partition key value of the item itself.
*
*
* -
*
* SizeEstimateRangeGB
- An estimate of item collection size, in gigabytes. This value is a
* two-element array containing a lower bound and an upper bound for the estimate. The estimate includes the
* size of all the items in the table, plus the size of all attributes projected into all of the local secondary
* indexes on that table. Use this estimate to measure whether a local secondary index is approaching its size
* limit.
*
*
* The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the
* estimate.
*
*
*
* This is a convenience that creates an instance of the {@link ItemCollectionMetrics.Builder} avoiding the need
* to create one manually via {@link ItemCollectionMetrics#builder()}.
*
* When the {@link Consumer} completes, {@link ItemCollectionMetrics.Builder#build()} is called immediately and
* its result is passed to {@link #itemCollectionMetrics(ItemCollectionMetrics)}.
*
* @param itemCollectionMetrics
* a consumer that will call methods on {@link ItemCollectionMetrics.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #itemCollectionMetrics(ItemCollectionMetrics)
*/
default Builder itemCollectionMetrics(Consumer itemCollectionMetrics) {
return itemCollectionMetrics(ItemCollectionMetrics.builder().applyMutation(itemCollectionMetrics).build());
}
}
static final class BuilderImpl extends DynamoDbResponse.BuilderImpl implements Builder {
private Map attributes = DefaultSdkAutoConstructMap.getInstance();
private ConsumedCapacity consumedCapacity;
private ItemCollectionMetrics itemCollectionMetrics;
private BuilderImpl() {
}
private BuilderImpl(DeleteItemResponse model) {
super(model);
attributes(model.attributes);
consumedCapacity(model.consumedCapacity);
itemCollectionMetrics(model.itemCollectionMetrics);
}
public final Map getAttributes() {
return attributes != null ? CollectionUtils.mapValues(attributes, AttributeValue::toBuilder) : null;
}
@Override
public final Builder attributes(Map attributes) {
this.attributes = AttributeMapCopier.copy(attributes);
return this;
}
public final void setAttributes(Map attributes) {
this.attributes = AttributeMapCopier.copyFromBuilder(attributes);
}
public final ConsumedCapacity.Builder getConsumedCapacity() {
return consumedCapacity != null ? consumedCapacity.toBuilder() : null;
}
@Override
public final Builder consumedCapacity(ConsumedCapacity consumedCapacity) {
this.consumedCapacity = consumedCapacity;
return this;
}
public final void setConsumedCapacity(ConsumedCapacity.BuilderImpl consumedCapacity) {
this.consumedCapacity = consumedCapacity != null ? consumedCapacity.build() : null;
}
public final ItemCollectionMetrics.Builder getItemCollectionMetrics() {
return itemCollectionMetrics != null ? itemCollectionMetrics.toBuilder() : null;
}
@Override
public final Builder itemCollectionMetrics(ItemCollectionMetrics itemCollectionMetrics) {
this.itemCollectionMetrics = itemCollectionMetrics;
return this;
}
public final void setItemCollectionMetrics(ItemCollectionMetrics.BuilderImpl itemCollectionMetrics) {
this.itemCollectionMetrics = itemCollectionMetrics != null ? itemCollectionMetrics.build() : null;
}
@Override
public DeleteItemResponse build() {
return new DeleteItemResponse(this);
}
}
}