software.amazon.awssdk.services.ses.model.BouncedRecipientInfo Maven / Gradle / Ivy
/*
* 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.ses.model;
import java.beans.Transient;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
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;
/**
*
* Recipient-related information to include in the Delivery Status Notification (DSN) when an email that Amazon SES
* receives on your behalf bounces.
*
*
* For information about receiving email through Amazon SES, see the Amazon SES Developer Guide.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class BouncedRecipientInfo implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField RECIPIENT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Recipient").getter(getter(BouncedRecipientInfo::recipient)).setter(setter(Builder::recipient))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Recipient").build()).build();
private static final SdkField RECIPIENT_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RecipientArn").getter(getter(BouncedRecipientInfo::recipientArn)).setter(setter(Builder::recipientArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecipientArn").build()).build();
private static final SdkField BOUNCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("BounceType").getter(getter(BouncedRecipientInfo::bounceTypeAsString))
.setter(setter(Builder::bounceType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BounceType").build()).build();
private static final SdkField RECIPIENT_DSN_FIELDS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("RecipientDsnFields")
.getter(getter(BouncedRecipientInfo::recipientDsnFields)).setter(setter(Builder::recipientDsnFields))
.constructor(RecipientDsnFields::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecipientDsnFields").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(RECIPIENT_FIELD,
RECIPIENT_ARN_FIELD, BOUNCE_TYPE_FIELD, RECIPIENT_DSN_FIELDS_FIELD));
private static final long serialVersionUID = 1L;
private final String recipient;
private final String recipientArn;
private final String bounceType;
private final RecipientDsnFields recipientDsnFields;
private BouncedRecipientInfo(BuilderImpl builder) {
this.recipient = builder.recipient;
this.recipientArn = builder.recipientArn;
this.bounceType = builder.bounceType;
this.recipientDsnFields = builder.recipientDsnFields;
}
/**
*
* The email address of the recipient of the bounced email.
*
*
* @return The email address of the recipient of the bounced email.
*/
public final String recipient() {
return recipient;
}
/**
*
* This parameter is used only for sending authorization. It is the ARN of the identity that is associated with the
* sending authorization policy that permits you to receive email for the recipient of the bounced email. For more
* information about sending authorization, see the Amazon SES Developer
* Guide.
*
*
* @return This parameter is used only for sending authorization. It is the ARN of the identity that is associated
* with the sending authorization policy that permits you to receive email for the recipient of the bounced
* email. For more information about sending authorization, see the Amazon SES
* Developer Guide.
*/
public final String recipientArn() {
return recipientArn;
}
/**
*
* The reason for the bounce. You must provide either this parameter or RecipientDsnFields
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #bounceType} will
* return {@link BounceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #bounceTypeAsString}.
*
*
* @return The reason for the bounce. You must provide either this parameter or RecipientDsnFields
.
* @see BounceType
*/
public final BounceType bounceType() {
return BounceType.fromValue(bounceType);
}
/**
*
* The reason for the bounce. You must provide either this parameter or RecipientDsnFields
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #bounceType} will
* return {@link BounceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #bounceTypeAsString}.
*
*
* @return The reason for the bounce. You must provide either this parameter or RecipientDsnFields
.
* @see BounceType
*/
public final String bounceTypeAsString() {
return bounceType;
}
/**
*
* Recipient-related DSN fields, most of which would normally be filled in automatically when provided with a
* BounceType
. You must provide either this parameter or BounceType
.
*
*
* @return Recipient-related DSN fields, most of which would normally be filled in automatically when provided with
* a BounceType
. You must provide either this parameter or BounceType
.
*/
public final RecipientDsnFields recipientDsnFields() {
return recipientDsnFields;
}
@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(recipient());
hashCode = 31 * hashCode + Objects.hashCode(recipientArn());
hashCode = 31 * hashCode + Objects.hashCode(bounceTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(recipientDsnFields());
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 BouncedRecipientInfo)) {
return false;
}
BouncedRecipientInfo other = (BouncedRecipientInfo) obj;
return Objects.equals(recipient(), other.recipient()) && Objects.equals(recipientArn(), other.recipientArn())
&& Objects.equals(bounceTypeAsString(), other.bounceTypeAsString())
&& Objects.equals(recipientDsnFields(), other.recipientDsnFields());
}
/**
* 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("BouncedRecipientInfo").add("Recipient", recipient()).add("RecipientArn", recipientArn())
.add("BounceType", bounceTypeAsString()).add("RecipientDsnFields", recipientDsnFields()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Recipient":
return Optional.ofNullable(clazz.cast(recipient()));
case "RecipientArn":
return Optional.ofNullable(clazz.cast(recipientArn()));
case "BounceType":
return Optional.ofNullable(clazz.cast(bounceTypeAsString()));
case "RecipientDsnFields":
return Optional.ofNullable(clazz.cast(recipientDsnFields()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function