
software.amazon.awssdk.services.dynamodb.model.ProvisionedThroughputDescription 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.time.Instant;
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.services.dynamodb.transform.ProvisionedThroughputDescriptionMarshaller;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents the provisioned throughput settings for the table, consisting of read and write capacity units, along with
* data about increases and decreases.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ProvisionedThroughputDescription implements StructuredPojo,
ToCopyableBuilder {
private final Instant lastIncreaseDateTime;
private final Instant lastDecreaseDateTime;
private final Long numberOfDecreasesToday;
private final Long readCapacityUnits;
private final Long writeCapacityUnits;
private ProvisionedThroughputDescription(BuilderImpl builder) {
this.lastIncreaseDateTime = builder.lastIncreaseDateTime;
this.lastDecreaseDateTime = builder.lastDecreaseDateTime;
this.numberOfDecreasesToday = builder.numberOfDecreasesToday;
this.readCapacityUnits = builder.readCapacityUnits;
this.writeCapacityUnits = builder.writeCapacityUnits;
}
/**
*
* The date and time of the last provisioned throughput increase for this table.
*
*
* @return The date and time of the last provisioned throughput increase for this table.
*/
public Instant lastIncreaseDateTime() {
return lastIncreaseDateTime;
}
/**
*
* The date and time of the last provisioned throughput decrease for this table.
*
*
* @return The date and time of the last provisioned throughput decrease for this table.
*/
public Instant lastDecreaseDateTime() {
return lastDecreaseDateTime;
}
/**
*
* The number of provisioned throughput decreases for this table during this UTC calendar day. For current maximums
* on provisioned throughput decreases, see Limits in the Amazon
* DynamoDB Developer Guide.
*
*
* @return The number of provisioned throughput decreases for this table during this UTC calendar day. For current
* maximums on provisioned throughput decreases, see Limits in the
* Amazon DynamoDB Developer Guide.
*/
public Long numberOfDecreasesToday() {
return numberOfDecreasesToday;
}
/**
*
* The maximum number of strongly consistent reads consumed per second before DynamoDB returns a
* ThrottlingException
. Eventually consistent reads require less effort than strongly consistent reads,
* so a setting of 50 ReadCapacityUnits
per second provides 100 eventually consistent
* ReadCapacityUnits
per second.
*
*
* @return The maximum number of strongly consistent reads consumed per second before DynamoDB returns a
* ThrottlingException
. Eventually consistent reads require less effort than strongly
* consistent reads, so a setting of 50 ReadCapacityUnits
per second provides 100 eventually
* consistent ReadCapacityUnits
per second.
*/
public Long readCapacityUnits() {
return readCapacityUnits;
}
/**
*
* The maximum number of writes consumed per second before DynamoDB returns a ThrottlingException
.
*
*
* @return The maximum number of writes consumed per second before DynamoDB returns a
* ThrottlingException
.
*/
public Long writeCapacityUnits() {
return writeCapacityUnits;
}
@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(lastIncreaseDateTime());
hashCode = 31 * hashCode + Objects.hashCode(lastDecreaseDateTime());
hashCode = 31 * hashCode + Objects.hashCode(numberOfDecreasesToday());
hashCode = 31 * hashCode + Objects.hashCode(readCapacityUnits());
hashCode = 31 * hashCode + Objects.hashCode(writeCapacityUnits());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ProvisionedThroughputDescription)) {
return false;
}
ProvisionedThroughputDescription other = (ProvisionedThroughputDescription) obj;
return Objects.equals(lastIncreaseDateTime(), other.lastIncreaseDateTime())
&& Objects.equals(lastDecreaseDateTime(), other.lastDecreaseDateTime())
&& Objects.equals(numberOfDecreasesToday(), other.numberOfDecreasesToday())
&& Objects.equals(readCapacityUnits(), other.readCapacityUnits())
&& Objects.equals(writeCapacityUnits(), other.writeCapacityUnits());
}
@Override
public String toString() {
return ToString.builder("ProvisionedThroughputDescription").add("LastIncreaseDateTime", lastIncreaseDateTime())
.add("LastDecreaseDateTime", lastDecreaseDateTime()).add("NumberOfDecreasesToday", numberOfDecreasesToday())
.add("ReadCapacityUnits", readCapacityUnits()).add("WriteCapacityUnits", writeCapacityUnits()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "LastIncreaseDateTime":
return Optional.ofNullable(clazz.cast(lastIncreaseDateTime()));
case "LastDecreaseDateTime":
return Optional.ofNullable(clazz.cast(lastDecreaseDateTime()));
case "NumberOfDecreasesToday":
return Optional.ofNullable(clazz.cast(numberOfDecreasesToday()));
case "ReadCapacityUnits":
return Optional.ofNullable(clazz.cast(readCapacityUnits()));
case "WriteCapacityUnits":
return Optional.ofNullable(clazz.cast(writeCapacityUnits()));
default:
return Optional.empty();
}
}
@SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
ProvisionedThroughputDescriptionMarshaller.getInstance().marshall(this, protocolMarshaller);
}
public interface Builder extends CopyableBuilder {
/**
*
* The date and time of the last provisioned throughput increase for this table.
*
*
* @param lastIncreaseDateTime
* The date and time of the last provisioned throughput increase for this table.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder lastIncreaseDateTime(Instant lastIncreaseDateTime);
/**
*
* The date and time of the last provisioned throughput decrease for this table.
*
*
* @param lastDecreaseDateTime
* The date and time of the last provisioned throughput decrease for this table.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder lastDecreaseDateTime(Instant lastDecreaseDateTime);
/**
*
* The number of provisioned throughput decreases for this table during this UTC calendar day. For current
* maximums on provisioned throughput decreases, see Limits in the
* Amazon DynamoDB Developer Guide.
*
*
* @param numberOfDecreasesToday
* The number of provisioned throughput decreases for this table during this UTC calendar day. For
* current maximums on provisioned throughput decreases, see Limits in the
* Amazon DynamoDB Developer Guide.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder numberOfDecreasesToday(Long numberOfDecreasesToday);
/**
*
* The maximum number of strongly consistent reads consumed per second before DynamoDB returns a
* ThrottlingException
. Eventually consistent reads require less effort than strongly consistent
* reads, so a setting of 50 ReadCapacityUnits
per second provides 100 eventually consistent
* ReadCapacityUnits
per second.
*
*
* @param readCapacityUnits
* The maximum number of strongly consistent reads consumed per second before DynamoDB returns a
* ThrottlingException
. Eventually consistent reads require less effort than strongly
* consistent reads, so a setting of 50 ReadCapacityUnits
per second provides 100 eventually
* consistent ReadCapacityUnits
per second.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder readCapacityUnits(Long readCapacityUnits);
/**
*
* The maximum number of writes consumed per second before DynamoDB returns a ThrottlingException
.
*
*
* @param writeCapacityUnits
* The maximum number of writes consumed per second before DynamoDB returns a
* ThrottlingException
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder writeCapacityUnits(Long writeCapacityUnits);
}
static final class BuilderImpl implements Builder {
private Instant lastIncreaseDateTime;
private Instant lastDecreaseDateTime;
private Long numberOfDecreasesToday;
private Long readCapacityUnits;
private Long writeCapacityUnits;
private BuilderImpl() {
}
private BuilderImpl(ProvisionedThroughputDescription model) {
lastIncreaseDateTime(model.lastIncreaseDateTime);
lastDecreaseDateTime(model.lastDecreaseDateTime);
numberOfDecreasesToday(model.numberOfDecreasesToday);
readCapacityUnits(model.readCapacityUnits);
writeCapacityUnits(model.writeCapacityUnits);
}
public final Instant getLastIncreaseDateTime() {
return lastIncreaseDateTime;
}
@Override
public final Builder lastIncreaseDateTime(Instant lastIncreaseDateTime) {
this.lastIncreaseDateTime = lastIncreaseDateTime;
return this;
}
public final void setLastIncreaseDateTime(Instant lastIncreaseDateTime) {
this.lastIncreaseDateTime = lastIncreaseDateTime;
}
public final Instant getLastDecreaseDateTime() {
return lastDecreaseDateTime;
}
@Override
public final Builder lastDecreaseDateTime(Instant lastDecreaseDateTime) {
this.lastDecreaseDateTime = lastDecreaseDateTime;
return this;
}
public final void setLastDecreaseDateTime(Instant lastDecreaseDateTime) {
this.lastDecreaseDateTime = lastDecreaseDateTime;
}
public final Long getNumberOfDecreasesToday() {
return numberOfDecreasesToday;
}
@Override
public final Builder numberOfDecreasesToday(Long numberOfDecreasesToday) {
this.numberOfDecreasesToday = numberOfDecreasesToday;
return this;
}
public final void setNumberOfDecreasesToday(Long numberOfDecreasesToday) {
this.numberOfDecreasesToday = numberOfDecreasesToday;
}
public final Long getReadCapacityUnits() {
return readCapacityUnits;
}
@Override
public final Builder readCapacityUnits(Long readCapacityUnits) {
this.readCapacityUnits = readCapacityUnits;
return this;
}
public final void setReadCapacityUnits(Long readCapacityUnits) {
this.readCapacityUnits = readCapacityUnits;
}
public final Long getWriteCapacityUnits() {
return writeCapacityUnits;
}
@Override
public final Builder writeCapacityUnits(Long writeCapacityUnits) {
this.writeCapacityUnits = writeCapacityUnits;
return this;
}
public final void setWriteCapacityUnits(Long writeCapacityUnits) {
this.writeCapacityUnits = writeCapacityUnits;
}
@Override
public ProvisionedThroughputDescription build() {
return new ProvisionedThroughputDescription(this);
}
}
}