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

software.amazon.awssdk.services.dynamodb.model.ConsumedCapacity 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.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
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.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.services.dynamodb.transform.ConsumedCapacityMarshaller;
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 StructuredPojo, ToCopyableBuilder { private final String tableName; private final Double capacityUnits; 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.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 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; } /** *

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

* * @return The amount of throughput consumed on each local index affected by the operation. */ public Map localSecondaryIndexes() { return localSecondaryIndexes; } /** *

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

* * @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 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(table()); hashCode = 31 * hashCode + Objects.hashCode(localSecondaryIndexes()); hashCode = 31 * hashCode + Objects.hashCode(globalSecondaryIndexes()); return hashCode; } @Override public boolean equals(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(table(), other.table()) && Objects.equals(localSecondaryIndexes(), other.localSecondaryIndexes()) && Objects.equals(globalSecondaryIndexes(), other.globalSecondaryIndexes()); } @Override public String toString() { return ToString.builder("ConsumedCapacity").add("TableName", tableName()).add("CapacityUnits", capacityUnits()) .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 "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(); } } @SdkInternalApi @Override public void marshall(ProtocolMarshaller protocolMarshaller) { ConsumedCapacityMarshaller.getInstance().marshall(this, protocolMarshaller); } public interface Builder extends 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 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 Capacity table; private Map localSecondaryIndexes = DefaultSdkAutoConstructMap.getInstance(); private Map globalSecondaryIndexes = DefaultSdkAutoConstructMap.getInstance(); private BuilderImpl() { } private BuilderImpl(ConsumedCapacity model) { tableName(model.tableName); capacityUnits(model.capacityUnits); 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 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); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy