
software.amazon.awssdk.services.dynamodb.model.ReplicaSettingsDescription 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.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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.DefaultSdkAutoConstructList;
import software.amazon.awssdk.services.dynamodb.transform.ReplicaSettingsDescriptionMarshaller;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents the properties of a replica.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ReplicaSettingsDescription implements StructuredPojo,
ToCopyableBuilder {
private final String regionName;
private final String replicaStatus;
private final Long replicaProvisionedReadCapacityUnits;
private final Long replicaProvisionedWriteCapacityUnits;
private final List replicaGlobalSecondaryIndexSettings;
private ReplicaSettingsDescription(BuilderImpl builder) {
this.regionName = builder.regionName;
this.replicaStatus = builder.replicaStatus;
this.replicaProvisionedReadCapacityUnits = builder.replicaProvisionedReadCapacityUnits;
this.replicaProvisionedWriteCapacityUnits = builder.replicaProvisionedWriteCapacityUnits;
this.replicaGlobalSecondaryIndexSettings = builder.replicaGlobalSecondaryIndexSettings;
}
/**
*
* The region name of the replica.
*
*
* @return The region name of the replica.
*/
public String regionName() {
return regionName;
}
/**
*
* The current state of the region:
*
*
* -
*
* CREATING
- The region is being created.
*
*
* -
*
* UPDATING
- The region is being updated.
*
*
* -
*
* DELETING
- The region is being deleted.
*
*
* -
*
* ACTIVE
- The region is ready for use.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #replicaStatus}
* will return {@link ReplicaStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #replicaStatusAsString}.
*
*
* @return The current state of the region:
*
* -
*
* CREATING
- The region is being created.
*
*
* -
*
* UPDATING
- The region is being updated.
*
*
* -
*
* DELETING
- The region is being deleted.
*
*
* -
*
* ACTIVE
- The region is ready for use.
*
*
* @see ReplicaStatus
*/
public ReplicaStatus replicaStatus() {
return ReplicaStatus.fromValue(replicaStatus);
}
/**
*
* The current state of the region:
*
*
* -
*
* CREATING
- The region is being created.
*
*
* -
*
* UPDATING
- The region is being updated.
*
*
* -
*
* DELETING
- The region is being deleted.
*
*
* -
*
* ACTIVE
- The region is ready for use.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #replicaStatus}
* will return {@link ReplicaStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #replicaStatusAsString}.
*
*
* @return The current state of the region:
*
* -
*
* CREATING
- The region is being created.
*
*
* -
*
* UPDATING
- The region is being updated.
*
*
* -
*
* DELETING
- The region is being deleted.
*
*
* -
*
* ACTIVE
- The region is ready for use.
*
*
* @see ReplicaStatus
*/
public String replicaStatusAsString() {
return replicaStatus;
}
/**
*
* The maximum number of strongly consistent reads consumed per second before DynamoDB returns a
* ThrottlingException
. For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide.
*
*
* @return The maximum number of strongly consistent reads consumed per second before DynamoDB returns a
* ThrottlingException
. For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide.
*/
public Long replicaProvisionedReadCapacityUnits() {
return replicaProvisionedReadCapacityUnits;
}
/**
*
* The maximum number of writes consumed per second before DynamoDB returns a ThrottlingException
. For
* more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide.
*
*
* @return The maximum number of writes consumed per second before DynamoDB returns a
* ThrottlingException
. For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide.
*/
public Long replicaProvisionedWriteCapacityUnits() {
return replicaProvisionedWriteCapacityUnits;
}
/**
*
* Replica global secondary index settings for the global table.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return Replica global secondary index settings for the global table.
*/
public List replicaGlobalSecondaryIndexSettings() {
return replicaGlobalSecondaryIndexSettings;
}
@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(regionName());
hashCode = 31 * hashCode + Objects.hashCode(replicaStatusAsString());
hashCode = 31 * hashCode + Objects.hashCode(replicaProvisionedReadCapacityUnits());
hashCode = 31 * hashCode + Objects.hashCode(replicaProvisionedWriteCapacityUnits());
hashCode = 31 * hashCode + Objects.hashCode(replicaGlobalSecondaryIndexSettings());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ReplicaSettingsDescription)) {
return false;
}
ReplicaSettingsDescription other = (ReplicaSettingsDescription) obj;
return Objects.equals(regionName(), other.regionName())
&& Objects.equals(replicaStatusAsString(), other.replicaStatusAsString())
&& Objects.equals(replicaProvisionedReadCapacityUnits(), other.replicaProvisionedReadCapacityUnits())
&& Objects.equals(replicaProvisionedWriteCapacityUnits(), other.replicaProvisionedWriteCapacityUnits())
&& Objects.equals(replicaGlobalSecondaryIndexSettings(), other.replicaGlobalSecondaryIndexSettings());
}
@Override
public String toString() {
return ToString.builder("ReplicaSettingsDescription").add("RegionName", regionName())
.add("ReplicaStatus", replicaStatusAsString())
.add("ReplicaProvisionedReadCapacityUnits", replicaProvisionedReadCapacityUnits())
.add("ReplicaProvisionedWriteCapacityUnits", replicaProvisionedWriteCapacityUnits())
.add("ReplicaGlobalSecondaryIndexSettings", replicaGlobalSecondaryIndexSettings()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "RegionName":
return Optional.ofNullable(clazz.cast(regionName()));
case "ReplicaStatus":
return Optional.ofNullable(clazz.cast(replicaStatusAsString()));
case "ReplicaProvisionedReadCapacityUnits":
return Optional.ofNullable(clazz.cast(replicaProvisionedReadCapacityUnits()));
case "ReplicaProvisionedWriteCapacityUnits":
return Optional.ofNullable(clazz.cast(replicaProvisionedWriteCapacityUnits()));
case "ReplicaGlobalSecondaryIndexSettings":
return Optional.ofNullable(clazz.cast(replicaGlobalSecondaryIndexSettings()));
default:
return Optional.empty();
}
}
@SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
ReplicaSettingsDescriptionMarshaller.getInstance().marshall(this, protocolMarshaller);
}
public interface Builder extends CopyableBuilder {
/**
*
* The region name of the replica.
*
*
* @param regionName
* The region name of the replica.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder regionName(String regionName);
/**
*
* The current state of the region:
*
*
* -
*
* CREATING
- The region is being created.
*
*
* -
*
* UPDATING
- The region is being updated.
*
*
* -
*
* DELETING
- The region is being deleted.
*
*
* -
*
* ACTIVE
- The region is ready for use.
*
*
*
*
* @param replicaStatus
* The current state of the region:
*
* -
*
* CREATING
- The region is being created.
*
*
* -
*
* UPDATING
- The region is being updated.
*
*
* -
*
* DELETING
- The region is being deleted.
*
*
* -
*
* ACTIVE
- The region is ready for use.
*
*
* @see ReplicaStatus
* @return Returns a reference to this object so that method calls can be chained together.
* @see ReplicaStatus
*/
Builder replicaStatus(String replicaStatus);
/**
*
* The current state of the region:
*
*
* -
*
* CREATING
- The region is being created.
*
*
* -
*
* UPDATING
- The region is being updated.
*
*
* -
*
* DELETING
- The region is being deleted.
*
*
* -
*
* ACTIVE
- The region is ready for use.
*
*
*
*
* @param replicaStatus
* The current state of the region:
*
* -
*
* CREATING
- The region is being created.
*
*
* -
*
* UPDATING
- The region is being updated.
*
*
* -
*
* DELETING
- The region is being deleted.
*
*
* -
*
* ACTIVE
- The region is ready for use.
*
*
* @see ReplicaStatus
* @return Returns a reference to this object so that method calls can be chained together.
* @see ReplicaStatus
*/
Builder replicaStatus(ReplicaStatus replicaStatus);
/**
*
* The maximum number of strongly consistent reads consumed per second before DynamoDB returns a
* ThrottlingException
. For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide.
*
*
* @param replicaProvisionedReadCapacityUnits
* The maximum number of strongly consistent reads consumed per second before DynamoDB returns a
* ThrottlingException
. For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder replicaProvisionedReadCapacityUnits(Long replicaProvisionedReadCapacityUnits);
/**
*
* The maximum number of writes consumed per second before DynamoDB returns a ThrottlingException
.
* For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide.
*
*
* @param replicaProvisionedWriteCapacityUnits
* The maximum number of writes consumed per second before DynamoDB returns a
* ThrottlingException
. For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder replicaProvisionedWriteCapacityUnits(Long replicaProvisionedWriteCapacityUnits);
/**
*
* Replica global secondary index settings for the global table.
*
*
* @param replicaGlobalSecondaryIndexSettings
* Replica global secondary index settings for the global table.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder replicaGlobalSecondaryIndexSettings(
Collection replicaGlobalSecondaryIndexSettings);
/**
*
* Replica global secondary index settings for the global table.
*
*
* @param replicaGlobalSecondaryIndexSettings
* Replica global secondary index settings for the global table.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder replicaGlobalSecondaryIndexSettings(
ReplicaGlobalSecondaryIndexSettingsDescription... replicaGlobalSecondaryIndexSettings);
/**
*
* Replica global secondary index settings for the global table.
*
* This is a convenience that creates an instance of the {@link List
* .Builder} avoiding the need to create one manually via
* {@link List#builder()}.
*
* When the {@link Consumer} completes, {@link List
* .Builder#build()} is called immediately and its result is
* passed to {@link #replicaGlobalSecondaryIndexSettings(List)}.
*
* @param replicaGlobalSecondaryIndexSettings
* a consumer that will call methods on {@link List
* .Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #replicaGlobalSecondaryIndexSettings(List)
*/
Builder replicaGlobalSecondaryIndexSettings(
Consumer... replicaGlobalSecondaryIndexSettings);
}
static final class BuilderImpl implements Builder {
private String regionName;
private String replicaStatus;
private Long replicaProvisionedReadCapacityUnits;
private Long replicaProvisionedWriteCapacityUnits;
private List replicaGlobalSecondaryIndexSettings = DefaultSdkAutoConstructList
.getInstance();
private BuilderImpl() {
}
private BuilderImpl(ReplicaSettingsDescription model) {
regionName(model.regionName);
replicaStatus(model.replicaStatus);
replicaProvisionedReadCapacityUnits(model.replicaProvisionedReadCapacityUnits);
replicaProvisionedWriteCapacityUnits(model.replicaProvisionedWriteCapacityUnits);
replicaGlobalSecondaryIndexSettings(model.replicaGlobalSecondaryIndexSettings);
}
public final String getRegionName() {
return regionName;
}
@Override
public final Builder regionName(String regionName) {
this.regionName = regionName;
return this;
}
public final void setRegionName(String regionName) {
this.regionName = regionName;
}
public final String getReplicaStatus() {
return replicaStatus;
}
@Override
public final Builder replicaStatus(String replicaStatus) {
this.replicaStatus = replicaStatus;
return this;
}
@Override
public final Builder replicaStatus(ReplicaStatus replicaStatus) {
this.replicaStatus(replicaStatus.toString());
return this;
}
public final void setReplicaStatus(String replicaStatus) {
this.replicaStatus = replicaStatus;
}
public final Long getReplicaProvisionedReadCapacityUnits() {
return replicaProvisionedReadCapacityUnits;
}
@Override
public final Builder replicaProvisionedReadCapacityUnits(Long replicaProvisionedReadCapacityUnits) {
this.replicaProvisionedReadCapacityUnits = replicaProvisionedReadCapacityUnits;
return this;
}
public final void setReplicaProvisionedReadCapacityUnits(Long replicaProvisionedReadCapacityUnits) {
this.replicaProvisionedReadCapacityUnits = replicaProvisionedReadCapacityUnits;
}
public final Long getReplicaProvisionedWriteCapacityUnits() {
return replicaProvisionedWriteCapacityUnits;
}
@Override
public final Builder replicaProvisionedWriteCapacityUnits(Long replicaProvisionedWriteCapacityUnits) {
this.replicaProvisionedWriteCapacityUnits = replicaProvisionedWriteCapacityUnits;
return this;
}
public final void setReplicaProvisionedWriteCapacityUnits(Long replicaProvisionedWriteCapacityUnits) {
this.replicaProvisionedWriteCapacityUnits = replicaProvisionedWriteCapacityUnits;
}
public final Collection getReplicaGlobalSecondaryIndexSettings() {
return replicaGlobalSecondaryIndexSettings != null ? replicaGlobalSecondaryIndexSettings.stream()
.map(ReplicaGlobalSecondaryIndexSettingsDescription::toBuilder).collect(Collectors.toList()) : null;
}
@Override
public final Builder replicaGlobalSecondaryIndexSettings(
Collection replicaGlobalSecondaryIndexSettings) {
this.replicaGlobalSecondaryIndexSettings = ReplicaGlobalSecondaryIndexSettingsDescriptionListCopier
.copy(replicaGlobalSecondaryIndexSettings);
return this;
}
@Override
@SafeVarargs
public final Builder replicaGlobalSecondaryIndexSettings(
ReplicaGlobalSecondaryIndexSettingsDescription... replicaGlobalSecondaryIndexSettings) {
replicaGlobalSecondaryIndexSettings(Arrays.asList(replicaGlobalSecondaryIndexSettings));
return this;
}
@Override
@SafeVarargs
public final Builder replicaGlobalSecondaryIndexSettings(
Consumer... replicaGlobalSecondaryIndexSettings) {
replicaGlobalSecondaryIndexSettings(Stream.of(replicaGlobalSecondaryIndexSettings)
.map(c -> ReplicaGlobalSecondaryIndexSettingsDescription.builder().applyMutation(c).build())
.collect(Collectors.toList()));
return this;
}
public final void setReplicaGlobalSecondaryIndexSettings(
Collection replicaGlobalSecondaryIndexSettings) {
this.replicaGlobalSecondaryIndexSettings = ReplicaGlobalSecondaryIndexSettingsDescriptionListCopier
.copyFromBuilder(replicaGlobalSecondaryIndexSettings);
}
@Override
public ReplicaSettingsDescription build() {
return new ReplicaSettingsDescription(this);
}
}
}