software.amazon.awssdk.services.elasticache.model.GlobalReplicationGroupMember Maven / Gradle / Ivy
Show all versions of elasticache Show documentation
/*
* Copyright 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.elasticache.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* A member of a Global datastore. It contains the Replication Group Id, the Amazon region and the role of the
* replication group.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class GlobalReplicationGroupMember implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField REPLICATION_GROUP_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ReplicationGroupId").getter(getter(GlobalReplicationGroupMember::replicationGroupId))
.setter(setter(Builder::replicationGroupId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReplicationGroupId").build())
.build();
private static final SdkField REPLICATION_GROUP_REGION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ReplicationGroupRegion").getter(getter(GlobalReplicationGroupMember::replicationGroupRegion))
.setter(setter(Builder::replicationGroupRegion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReplicationGroupRegion").build())
.build();
private static final SdkField ROLE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Role")
.getter(getter(GlobalReplicationGroupMember::role)).setter(setter(Builder::role))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Role").build()).build();
private static final SdkField AUTOMATIC_FAILOVER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AutomaticFailover").getter(getter(GlobalReplicationGroupMember::automaticFailoverAsString))
.setter(setter(Builder::automaticFailover))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AutomaticFailover").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(GlobalReplicationGroupMember::status)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(REPLICATION_GROUP_ID_FIELD,
REPLICATION_GROUP_REGION_FIELD, ROLE_FIELD, AUTOMATIC_FAILOVER_FIELD, STATUS_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private static final long serialVersionUID = 1L;
private final String replicationGroupId;
private final String replicationGroupRegion;
private final String role;
private final String automaticFailover;
private final String status;
private GlobalReplicationGroupMember(BuilderImpl builder) {
this.replicationGroupId = builder.replicationGroupId;
this.replicationGroupRegion = builder.replicationGroupRegion;
this.role = builder.role;
this.automaticFailover = builder.automaticFailover;
this.status = builder.status;
}
/**
*
* The replication group id of the Global datastore member.
*
*
* @return The replication group id of the Global datastore member.
*/
public final String replicationGroupId() {
return replicationGroupId;
}
/**
*
* The Amazon region of the Global datastore member.
*
*
* @return The Amazon region of the Global datastore member.
*/
public final String replicationGroupRegion() {
return replicationGroupRegion;
}
/**
*
* Indicates the role of the replication group, primary or secondary.
*
*
* @return Indicates the role of the replication group, primary or secondary.
*/
public final String role() {
return role;
}
/**
*
* Indicates whether automatic failover is enabled for the replication group.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #automaticFailover}
* will return {@link AutomaticFailoverStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #automaticFailoverAsString}.
*
*
* @return Indicates whether automatic failover is enabled for the replication group.
* @see AutomaticFailoverStatus
*/
public final AutomaticFailoverStatus automaticFailover() {
return AutomaticFailoverStatus.fromValue(automaticFailover);
}
/**
*
* Indicates whether automatic failover is enabled for the replication group.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #automaticFailover}
* will return {@link AutomaticFailoverStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #automaticFailoverAsString}.
*
*
* @return Indicates whether automatic failover is enabled for the replication group.
* @see AutomaticFailoverStatus
*/
public final String automaticFailoverAsString() {
return automaticFailover;
}
/**
*
* The status of the membership of the replication group.
*
*
* @return The status of the membership of the replication group.
*/
public final String status() {
return status;
}
@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 final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(replicationGroupId());
hashCode = 31 * hashCode + Objects.hashCode(replicationGroupRegion());
hashCode = 31 * hashCode + Objects.hashCode(role());
hashCode = 31 * hashCode + Objects.hashCode(automaticFailoverAsString());
hashCode = 31 * hashCode + Objects.hashCode(status());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GlobalReplicationGroupMember)) {
return false;
}
GlobalReplicationGroupMember other = (GlobalReplicationGroupMember) obj;
return Objects.equals(replicationGroupId(), other.replicationGroupId())
&& Objects.equals(replicationGroupRegion(), other.replicationGroupRegion())
&& Objects.equals(role(), other.role())
&& Objects.equals(automaticFailoverAsString(), other.automaticFailoverAsString())
&& Objects.equals(status(), other.status());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("GlobalReplicationGroupMember").add("ReplicationGroupId", replicationGroupId())
.add("ReplicationGroupRegion", replicationGroupRegion()).add("Role", role())
.add("AutomaticFailover", automaticFailoverAsString()).add("Status", status()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ReplicationGroupId":
return Optional.ofNullable(clazz.cast(replicationGroupId()));
case "ReplicationGroupRegion":
return Optional.ofNullable(clazz.cast(replicationGroupRegion()));
case "Role":
return Optional.ofNullable(clazz.cast(role()));
case "AutomaticFailover":
return Optional.ofNullable(clazz.cast(automaticFailoverAsString()));
case "Status":
return Optional.ofNullable(clazz.cast(status()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Map> memberNameToFieldInitializer() {
Map> map = new HashMap<>();
map.put("ReplicationGroupId", REPLICATION_GROUP_ID_FIELD);
map.put("ReplicationGroupRegion", REPLICATION_GROUP_REGION_FIELD);
map.put("Role", ROLE_FIELD);
map.put("AutomaticFailover", AUTOMATIC_FAILOVER_FIELD);
map.put("Status", STATUS_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function