
software.amazon.awssdk.services.dynamodb.model.ReplicaSettingsUpdate 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.ReplicaSettingsUpdateMarshaller;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents the settings for a global table in a region that will be modified.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ReplicaSettingsUpdate implements StructuredPojo,
ToCopyableBuilder {
private final String regionName;
private final Long replicaProvisionedReadCapacityUnits;
private final List replicaGlobalSecondaryIndexSettingsUpdate;
private ReplicaSettingsUpdate(BuilderImpl builder) {
this.regionName = builder.regionName;
this.replicaProvisionedReadCapacityUnits = builder.replicaProvisionedReadCapacityUnits;
this.replicaGlobalSecondaryIndexSettingsUpdate = builder.replicaGlobalSecondaryIndexSettingsUpdate;
}
/**
*
* The region of the replica to be added.
*
*
* @return The region of the replica to be added.
*/
public String regionName() {
return regionName;
}
/**
*
* 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;
}
/**
*
* Represents the settings of a global secondary index for a global table that will be modified.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return Represents the settings of a global secondary index for a global table that will be modified.
*/
public List replicaGlobalSecondaryIndexSettingsUpdate() {
return replicaGlobalSecondaryIndexSettingsUpdate;
}
@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(replicaProvisionedReadCapacityUnits());
hashCode = 31 * hashCode + Objects.hashCode(replicaGlobalSecondaryIndexSettingsUpdate());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ReplicaSettingsUpdate)) {
return false;
}
ReplicaSettingsUpdate other = (ReplicaSettingsUpdate) obj;
return Objects.equals(regionName(), other.regionName())
&& Objects.equals(replicaProvisionedReadCapacityUnits(), other.replicaProvisionedReadCapacityUnits())
&& Objects.equals(replicaGlobalSecondaryIndexSettingsUpdate(), other.replicaGlobalSecondaryIndexSettingsUpdate());
}
@Override
public String toString() {
return ToString.builder("ReplicaSettingsUpdate").add("RegionName", regionName())
.add("ReplicaProvisionedReadCapacityUnits", replicaProvisionedReadCapacityUnits())
.add("ReplicaGlobalSecondaryIndexSettingsUpdate", replicaGlobalSecondaryIndexSettingsUpdate()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "RegionName":
return Optional.ofNullable(clazz.cast(regionName()));
case "ReplicaProvisionedReadCapacityUnits":
return Optional.ofNullable(clazz.cast(replicaProvisionedReadCapacityUnits()));
case "ReplicaGlobalSecondaryIndexSettingsUpdate":
return Optional.ofNullable(clazz.cast(replicaGlobalSecondaryIndexSettingsUpdate()));
default:
return Optional.empty();
}
}
@SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
ReplicaSettingsUpdateMarshaller.getInstance().marshall(this, protocolMarshaller);
}
public interface Builder extends CopyableBuilder {
/**
*
* The region of the replica to be added.
*
*
* @param regionName
* The region of the replica to be added.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder regionName(String regionName);
/**
*
* 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);
/**
*
* Represents the settings of a global secondary index for a global table that will be modified.
*
*
* @param replicaGlobalSecondaryIndexSettingsUpdate
* Represents the settings of a global secondary index for a global table that will be modified.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder replicaGlobalSecondaryIndexSettingsUpdate(
Collection replicaGlobalSecondaryIndexSettingsUpdate);
/**
*
* Represents the settings of a global secondary index for a global table that will be modified.
*
*
* @param replicaGlobalSecondaryIndexSettingsUpdate
* Represents the settings of a global secondary index for a global table that will be modified.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder replicaGlobalSecondaryIndexSettingsUpdate(
ReplicaGlobalSecondaryIndexSettingsUpdate... replicaGlobalSecondaryIndexSettingsUpdate);
/**
*
* Represents the settings of a global secondary index for a global table that will be modified.
*
* 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
* #replicaGlobalSecondaryIndexSettingsUpdate(List)}.
*
* @param replicaGlobalSecondaryIndexSettingsUpdate
* 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 #replicaGlobalSecondaryIndexSettingsUpdate(List)
*/
Builder replicaGlobalSecondaryIndexSettingsUpdate(
Consumer... replicaGlobalSecondaryIndexSettingsUpdate);
}
static final class BuilderImpl implements Builder {
private String regionName;
private Long replicaProvisionedReadCapacityUnits;
private List replicaGlobalSecondaryIndexSettingsUpdate = DefaultSdkAutoConstructList
.getInstance();
private BuilderImpl() {
}
private BuilderImpl(ReplicaSettingsUpdate model) {
regionName(model.regionName);
replicaProvisionedReadCapacityUnits(model.replicaProvisionedReadCapacityUnits);
replicaGlobalSecondaryIndexSettingsUpdate(model.replicaGlobalSecondaryIndexSettingsUpdate);
}
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 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 Collection getReplicaGlobalSecondaryIndexSettingsUpdate() {
return replicaGlobalSecondaryIndexSettingsUpdate != null ? replicaGlobalSecondaryIndexSettingsUpdate.stream()
.map(ReplicaGlobalSecondaryIndexSettingsUpdate::toBuilder).collect(Collectors.toList()) : null;
}
@Override
public final Builder replicaGlobalSecondaryIndexSettingsUpdate(
Collection replicaGlobalSecondaryIndexSettingsUpdate) {
this.replicaGlobalSecondaryIndexSettingsUpdate = ReplicaGlobalSecondaryIndexSettingsUpdateListCopier
.copy(replicaGlobalSecondaryIndexSettingsUpdate);
return this;
}
@Override
@SafeVarargs
public final Builder replicaGlobalSecondaryIndexSettingsUpdate(
ReplicaGlobalSecondaryIndexSettingsUpdate... replicaGlobalSecondaryIndexSettingsUpdate) {
replicaGlobalSecondaryIndexSettingsUpdate(Arrays.asList(replicaGlobalSecondaryIndexSettingsUpdate));
return this;
}
@Override
@SafeVarargs
public final Builder replicaGlobalSecondaryIndexSettingsUpdate(
Consumer... replicaGlobalSecondaryIndexSettingsUpdate) {
replicaGlobalSecondaryIndexSettingsUpdate(Stream.of(replicaGlobalSecondaryIndexSettingsUpdate)
.map(c -> ReplicaGlobalSecondaryIndexSettingsUpdate.builder().applyMutation(c).build())
.collect(Collectors.toList()));
return this;
}
public final void setReplicaGlobalSecondaryIndexSettingsUpdate(
Collection replicaGlobalSecondaryIndexSettingsUpdate) {
this.replicaGlobalSecondaryIndexSettingsUpdate = ReplicaGlobalSecondaryIndexSettingsUpdateListCopier
.copyFromBuilder(replicaGlobalSecondaryIndexSettingsUpdate);
}
@Override
public ReplicaSettingsUpdate build() {
return new ReplicaSettingsUpdate(this);
}
}
}