
software.amazon.awssdk.services.dynamodb.model.ReplicaUpdate 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.
/*
* 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.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.services.dynamodb.transform.ReplicaUpdateMarshaller;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents one of the following:
*
*
* -
*
* A new replica to be added to an existing global table.
*
*
* -
*
* New parameters for an existing replica.
*
*
* -
*
* An existing replica to be removed from an existing global table.
*
*
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ReplicaUpdate implements StructuredPojo, ToCopyableBuilder {
private final CreateReplicaAction create;
private final DeleteReplicaAction delete;
private ReplicaUpdate(BuilderImpl builder) {
this.create = builder.create;
this.delete = builder.delete;
}
/**
*
* The parameters required for creating a replica on an existing global table.
*
*
* @return The parameters required for creating a replica on an existing global table.
*/
public CreateReplicaAction create() {
return create;
}
/**
*
* The name of the existing replica to be removed.
*
*
* @return The name of the existing replica to be removed.
*/
public DeleteReplicaAction delete() {
return delete;
}
@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(create());
hashCode = 31 * hashCode + Objects.hashCode(delete());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ReplicaUpdate)) {
return false;
}
ReplicaUpdate other = (ReplicaUpdate) obj;
return Objects.equals(create(), other.create()) && Objects.equals(delete(), other.delete());
}
@Override
public String toString() {
return ToString.builder("ReplicaUpdate").add("Create", create()).add("Delete", delete()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Create":
return Optional.ofNullable(clazz.cast(create()));
case "Delete":
return Optional.ofNullable(clazz.cast(delete()));
default:
return Optional.empty();
}
}
@SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
ReplicaUpdateMarshaller.getInstance().marshall(this, protocolMarshaller);
}
public interface Builder extends CopyableBuilder {
/**
*
* The parameters required for creating a replica on an existing global table.
*
*
* @param create
* The parameters required for creating a replica on an existing global table.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder create(CreateReplicaAction create);
/**
*
* The parameters required for creating a replica on an existing global table.
*
* This is a convenience that creates an instance of the {@link CreateReplicaAction.Builder} avoiding the need
* to create one manually via {@link CreateReplicaAction#builder()}.
*
* When the {@link Consumer} completes, {@link CreateReplicaAction.Builder#build()} is called immediately and
* its result is passed to {@link #create(CreateReplicaAction)}.
*
* @param create
* a consumer that will call methods on {@link CreateReplicaAction.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #create(CreateReplicaAction)
*/
default Builder create(Consumer create) {
return create(CreateReplicaAction.builder().applyMutation(create).build());
}
/**
*
* The name of the existing replica to be removed.
*
*
* @param delete
* The name of the existing replica to be removed.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder delete(DeleteReplicaAction delete);
/**
*
* The name of the existing replica to be removed.
*
* This is a convenience that creates an instance of the {@link DeleteReplicaAction.Builder} avoiding the need
* to create one manually via {@link DeleteReplicaAction#builder()}.
*
* When the {@link Consumer} completes, {@link DeleteReplicaAction.Builder#build()} is called immediately and
* its result is passed to {@link #delete(DeleteReplicaAction)}.
*
* @param delete
* a consumer that will call methods on {@link DeleteReplicaAction.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #delete(DeleteReplicaAction)
*/
default Builder delete(Consumer delete) {
return delete(DeleteReplicaAction.builder().applyMutation(delete).build());
}
}
static final class BuilderImpl implements Builder {
private CreateReplicaAction create;
private DeleteReplicaAction delete;
private BuilderImpl() {
}
private BuilderImpl(ReplicaUpdate model) {
create(model.create);
delete(model.delete);
}
public final CreateReplicaAction.Builder getCreate() {
return create != null ? create.toBuilder() : null;
}
@Override
public final Builder create(CreateReplicaAction create) {
this.create = create;
return this;
}
public final void setCreate(CreateReplicaAction.BuilderImpl create) {
this.create = create != null ? create.build() : null;
}
public final DeleteReplicaAction.Builder getDelete() {
return delete != null ? delete.toBuilder() : null;
}
@Override
public final Builder delete(DeleteReplicaAction delete) {
this.delete = delete;
return this;
}
public final void setDelete(DeleteReplicaAction.BuilderImpl delete) {
this.delete = delete != null ? delete.build() : null;
}
@Override
public ReplicaUpdate build() {
return new ReplicaUpdate(this);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy