Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
software.amazon.awssdk.services.dynamodb.model.ConsumedCapacity Maven / Gradle / Ivy
Go to download
The AWS Java SDK for Amazon DynamoDB module holds the client classes that are used for communicating
with Amazon DynamoDB
Service
/*
* Copyright 2015-2020 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.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
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;
/**
*
* The capacity units consumed by an 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 request asked for it. For more information, see Provisioned
* Throughput in the Amazon DynamoDB Developer Guide .
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ConsumedCapacity implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField TABLE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(ConsumedCapacity::tableName)).setter(setter(Builder::tableName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TableName").build()).build();
private static final SdkField CAPACITY_UNITS_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.getter(getter(ConsumedCapacity::capacityUnits)).setter(setter(Builder::capacityUnits))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CapacityUnits").build()).build();
private static final SdkField READ_CAPACITY_UNITS_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.getter(getter(ConsumedCapacity::readCapacityUnits)).setter(setter(Builder::readCapacityUnits))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReadCapacityUnits").build()).build();
private static final SdkField WRITE_CAPACITY_UNITS_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.getter(getter(ConsumedCapacity::writeCapacityUnits)).setter(setter(Builder::writeCapacityUnits))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("WriteCapacityUnits").build())
.build();
private static final SdkField TABLE_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.getter(getter(ConsumedCapacity::table)).setter(setter(Builder::table)).constructor(Capacity::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Table").build()).build();
private static final SdkField> LOCAL_SECONDARY_INDEXES_FIELD = SdkField
.> builder(MarshallingType.MAP)
.getter(getter(ConsumedCapacity::localSecondaryIndexes))
.setter(setter(Builder::localSecondaryIndexes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LocalSecondaryIndexes").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Capacity::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final SdkField> GLOBAL_SECONDARY_INDEXES_FIELD = SdkField
.> builder(MarshallingType.MAP)
.getter(getter(ConsumedCapacity::globalSecondaryIndexes))
.setter(setter(Builder::globalSecondaryIndexes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("GlobalSecondaryIndexes").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Capacity::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TABLE_NAME_FIELD,
CAPACITY_UNITS_FIELD, READ_CAPACITY_UNITS_FIELD, WRITE_CAPACITY_UNITS_FIELD, TABLE_FIELD,
LOCAL_SECONDARY_INDEXES_FIELD, GLOBAL_SECONDARY_INDEXES_FIELD));
private static final long serialVersionUID = 1L;
private final String tableName;
private final Double capacityUnits;
private final Double readCapacityUnits;
private final Double writeCapacityUnits;
private final Capacity table;
private final Map localSecondaryIndexes;
private final Map globalSecondaryIndexes;
private ConsumedCapacity(BuilderImpl builder) {
this.tableName = builder.tableName;
this.capacityUnits = builder.capacityUnits;
this.readCapacityUnits = builder.readCapacityUnits;
this.writeCapacityUnits = builder.writeCapacityUnits;
this.table = builder.table;
this.localSecondaryIndexes = builder.localSecondaryIndexes;
this.globalSecondaryIndexes = builder.globalSecondaryIndexes;
}
/**
*
* The name of the table that was affected by the operation.
*
*
* @return The name of the table that was affected by the operation.
*/
public String tableName() {
return tableName;
}
/**
*
* The total number of capacity units consumed by the operation.
*
*
* @return The total number of capacity units consumed by the operation.
*/
public Double capacityUnits() {
return capacityUnits;
}
/**
*
* The total number of read capacity units consumed by the operation.
*
*
* @return The total number of read capacity units consumed by the operation.
*/
public Double readCapacityUnits() {
return readCapacityUnits;
}
/**
*
* The total number of write capacity units consumed by the operation.
*
*
* @return The total number of write capacity units consumed by the operation.
*/
public Double writeCapacityUnits() {
return writeCapacityUnits;
}
/**
*
* The amount of throughput consumed on the table affected by the operation.
*
*
* @return The amount of throughput consumed on the table affected by the operation.
*/
public Capacity table() {
return table;
}
/**
* Returns true if the LocalSecondaryIndexes 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 hasLocalSecondaryIndexes() {
return localSecondaryIndexes != null && !(localSecondaryIndexes instanceof SdkAutoConstructMap);
}
/**
*
* The amount of throughput consumed on each local index affected by the operation.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasLocalSecondaryIndexes()} to see if a value was sent in this field.
*
*
* @return The amount of throughput consumed on each local index affected by the operation.
*/
public Map localSecondaryIndexes() {
return localSecondaryIndexes;
}
/**
* Returns true if the GlobalSecondaryIndexes 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 hasGlobalSecondaryIndexes() {
return globalSecondaryIndexes != null && !(globalSecondaryIndexes instanceof SdkAutoConstructMap);
}
/**
*
* The amount of throughput consumed on each global index affected by the operation.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasGlobalSecondaryIndexes()} to see if a value was sent in this field.
*
*
* @return The amount of throughput consumed on each global index affected by the operation.
*/
public Map globalSecondaryIndexes() {
return globalSecondaryIndexes;
}
@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(tableName());
hashCode = 31 * hashCode + Objects.hashCode(capacityUnits());
hashCode = 31 * hashCode + Objects.hashCode(readCapacityUnits());
hashCode = 31 * hashCode + Objects.hashCode(writeCapacityUnits());
hashCode = 31 * hashCode + Objects.hashCode(table());
hashCode = 31 * hashCode + Objects.hashCode(localSecondaryIndexes());
hashCode = 31 * hashCode + Objects.hashCode(globalSecondaryIndexes());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ConsumedCapacity)) {
return false;
}
ConsumedCapacity other = (ConsumedCapacity) obj;
return Objects.equals(tableName(), other.tableName()) && Objects.equals(capacityUnits(), other.capacityUnits())
&& Objects.equals(readCapacityUnits(), other.readCapacityUnits())
&& Objects.equals(writeCapacityUnits(), other.writeCapacityUnits()) && Objects.equals(table(), other.table())
&& Objects.equals(localSecondaryIndexes(), other.localSecondaryIndexes())
&& Objects.equals(globalSecondaryIndexes(), other.globalSecondaryIndexes());
}
/**
* 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("ConsumedCapacity").add("TableName", tableName()).add("CapacityUnits", capacityUnits())
.add("ReadCapacityUnits", readCapacityUnits()).add("WriteCapacityUnits", writeCapacityUnits())
.add("Table", table()).add("LocalSecondaryIndexes", localSecondaryIndexes())
.add("GlobalSecondaryIndexes", globalSecondaryIndexes()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "TableName":
return Optional.ofNullable(clazz.cast(tableName()));
case "CapacityUnits":
return Optional.ofNullable(clazz.cast(capacityUnits()));
case "ReadCapacityUnits":
return Optional.ofNullable(clazz.cast(readCapacityUnits()));
case "WriteCapacityUnits":
return Optional.ofNullable(clazz.cast(writeCapacityUnits()));
case "Table":
return Optional.ofNullable(clazz.cast(table()));
case "LocalSecondaryIndexes":
return Optional.ofNullable(clazz.cast(localSecondaryIndexes()));
case "GlobalSecondaryIndexes":
return Optional.ofNullable(clazz.cast(globalSecondaryIndexes()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((ConsumedCapacity) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends SdkPojo, CopyableBuilder {
/**
*
* The name of the table that was affected by the operation.
*
*
* @param tableName
* The name of the table that was affected by the operation.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder tableName(String tableName);
/**
*
* The total number of capacity units consumed by the operation.
*
*
* @param capacityUnits
* The total number of capacity units consumed by the operation.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder capacityUnits(Double capacityUnits);
/**
*
* The total number of read capacity units consumed by the operation.
*
*
* @param readCapacityUnits
* The total number of read capacity units consumed by the operation.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder readCapacityUnits(Double readCapacityUnits);
/**
*
* The total number of write capacity units consumed by the operation.
*
*
* @param writeCapacityUnits
* The total number of write capacity units consumed by the operation.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder writeCapacityUnits(Double writeCapacityUnits);
/**
*
* The amount of throughput consumed on the table affected by the operation.
*
*
* @param table
* The amount of throughput consumed on the table affected by the operation.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder table(Capacity table);
/**
*
* The amount of throughput consumed on the table affected by the operation.
*
* This is a convenience that creates an instance of the {@link Capacity.Builder} avoiding the need to create
* one manually via {@link Capacity#builder()}.
*
* When the {@link Consumer} completes, {@link Capacity.Builder#build()} is called immediately and its result is
* passed to {@link #table(Capacity)}.
*
* @param table
* a consumer that will call methods on {@link Capacity.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #table(Capacity)
*/
default Builder table(Consumer table) {
return table(Capacity.builder().applyMutation(table).build());
}
/**
*
* The amount of throughput consumed on each local index affected by the operation.
*
*
* @param localSecondaryIndexes
* The amount of throughput consumed on each local index affected by the operation.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder localSecondaryIndexes(Map localSecondaryIndexes);
/**
*
* The amount of throughput consumed on each global index affected by the operation.
*
*
* @param globalSecondaryIndexes
* The amount of throughput consumed on each global index affected by the operation.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder globalSecondaryIndexes(Map globalSecondaryIndexes);
}
static final class BuilderImpl implements Builder {
private String tableName;
private Double capacityUnits;
private Double readCapacityUnits;
private Double writeCapacityUnits;
private Capacity table;
private Map localSecondaryIndexes = DefaultSdkAutoConstructMap.getInstance();
private Map globalSecondaryIndexes = DefaultSdkAutoConstructMap.getInstance();
private BuilderImpl() {
}
private BuilderImpl(ConsumedCapacity model) {
tableName(model.tableName);
capacityUnits(model.capacityUnits);
readCapacityUnits(model.readCapacityUnits);
writeCapacityUnits(model.writeCapacityUnits);
table(model.table);
localSecondaryIndexes(model.localSecondaryIndexes);
globalSecondaryIndexes(model.globalSecondaryIndexes);
}
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 Double getCapacityUnits() {
return capacityUnits;
}
@Override
public final Builder capacityUnits(Double capacityUnits) {
this.capacityUnits = capacityUnits;
return this;
}
public final void setCapacityUnits(Double capacityUnits) {
this.capacityUnits = capacityUnits;
}
public final Double getReadCapacityUnits() {
return readCapacityUnits;
}
@Override
public final Builder readCapacityUnits(Double readCapacityUnits) {
this.readCapacityUnits = readCapacityUnits;
return this;
}
public final void setReadCapacityUnits(Double readCapacityUnits) {
this.readCapacityUnits = readCapacityUnits;
}
public final Double getWriteCapacityUnits() {
return writeCapacityUnits;
}
@Override
public final Builder writeCapacityUnits(Double writeCapacityUnits) {
this.writeCapacityUnits = writeCapacityUnits;
return this;
}
public final void setWriteCapacityUnits(Double writeCapacityUnits) {
this.writeCapacityUnits = writeCapacityUnits;
}
public final Capacity.Builder getTable() {
return table != null ? table.toBuilder() : null;
}
@Override
public final Builder table(Capacity table) {
this.table = table;
return this;
}
public final void setTable(Capacity.BuilderImpl table) {
this.table = table != null ? table.build() : null;
}
public final Map getLocalSecondaryIndexes() {
return localSecondaryIndexes != null ? CollectionUtils.mapValues(localSecondaryIndexes, Capacity::toBuilder) : null;
}
@Override
public final Builder localSecondaryIndexes(Map localSecondaryIndexes) {
this.localSecondaryIndexes = SecondaryIndexesCapacityMapCopier.copy(localSecondaryIndexes);
return this;
}
public final void setLocalSecondaryIndexes(Map localSecondaryIndexes) {
this.localSecondaryIndexes = SecondaryIndexesCapacityMapCopier.copyFromBuilder(localSecondaryIndexes);
}
public final Map getGlobalSecondaryIndexes() {
return globalSecondaryIndexes != null ? CollectionUtils.mapValues(globalSecondaryIndexes, Capacity::toBuilder) : null;
}
@Override
public final Builder globalSecondaryIndexes(Map globalSecondaryIndexes) {
this.globalSecondaryIndexes = SecondaryIndexesCapacityMapCopier.copy(globalSecondaryIndexes);
return this;
}
public final void setGlobalSecondaryIndexes(Map globalSecondaryIndexes) {
this.globalSecondaryIndexes = SecondaryIndexesCapacityMapCopier.copyFromBuilder(globalSecondaryIndexes);
}
@Override
public ConsumedCapacity build() {
return new ConsumedCapacity(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}