All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.pinpoint.model.SimpleEmail Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon Pinpoint module holds the client classes that are used for communicating with Amazon Pinpoint Service

There is a newer version: 2.29.39
Show newest version
/*
 * 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.pinpoint.model;

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;

/**
 * 

* Specifies the contents of an email message, composed of a subject, a text part, and an HTML part. *

*/ @Generated("software.amazon.awssdk:codegen") public final class SimpleEmail implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField HTML_PART_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("HtmlPart").getter(getter(SimpleEmail::htmlPart)).setter(setter(Builder::htmlPart)) .constructor(SimpleEmailPart::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HtmlPart").build()).build(); private static final SdkField SUBJECT_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("Subject").getter(getter(SimpleEmail::subject)).setter(setter(Builder::subject)) .constructor(SimpleEmailPart::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Subject").build()).build(); private static final SdkField TEXT_PART_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("TextPart").getter(getter(SimpleEmail::textPart)).setter(setter(Builder::textPart)) .constructor(SimpleEmailPart::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TextPart").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(HTML_PART_FIELD, SUBJECT_FIELD, TEXT_PART_FIELD)); private static final long serialVersionUID = 1L; private final SimpleEmailPart htmlPart; private final SimpleEmailPart subject; private final SimpleEmailPart textPart; private SimpleEmail(BuilderImpl builder) { this.htmlPart = builder.htmlPart; this.subject = builder.subject; this.textPart = builder.textPart; } /** *

* The body of the email message, in HTML format. We recommend using HTML format for email clients that render HTML * content. You can include links, formatted text, and more in an HTML message. *

* * @return The body of the email message, in HTML format. We recommend using HTML format for email clients that * render HTML content. You can include links, formatted text, and more in an HTML message. */ public final SimpleEmailPart htmlPart() { return htmlPart; } /** *

* The subject line, or title, of the email. *

* * @return The subject line, or title, of the email. */ public final SimpleEmailPart subject() { return subject; } /** *

* The body of the email message, in plain text format. We recommend using plain text format for email clients that * don't render HTML content and clients that are connected to high-latency networks, such as mobile devices. *

* * @return The body of the email message, in plain text format. We recommend using plain text format for email * clients that don't render HTML content and clients that are connected to high-latency networks, such as * mobile devices. */ public final SimpleEmailPart textPart() { return textPart; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(htmlPart()); hashCode = 31 * hashCode + Objects.hashCode(subject()); hashCode = 31 * hashCode + Objects.hashCode(textPart()); 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 SimpleEmail)) { return false; } SimpleEmail other = (SimpleEmail) obj; return Objects.equals(htmlPart(), other.htmlPart()) && Objects.equals(subject(), other.subject()) && Objects.equals(textPart(), other.textPart()); } /** * 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("SimpleEmail").add("HtmlPart", htmlPart()).add("Subject", subject()).add("TextPart", textPart()) .build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "HtmlPart": return Optional.ofNullable(clazz.cast(htmlPart())); case "Subject": return Optional.ofNullable(clazz.cast(subject())); case "TextPart": return Optional.ofNullable(clazz.cast(textPart())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((SimpleEmail) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The body of the email message, in HTML format. We recommend using HTML format for email clients that render * HTML content. You can include links, formatted text, and more in an HTML message. *

* * @param htmlPart * The body of the email message, in HTML format. We recommend using HTML format for email clients that * render HTML content. You can include links, formatted text, and more in an HTML message. * @return Returns a reference to this object so that method calls can be chained together. */ Builder htmlPart(SimpleEmailPart htmlPart); /** *

* The body of the email message, in HTML format. We recommend using HTML format for email clients that render * HTML content. You can include links, formatted text, and more in an HTML message. *

* This is a convenience method that creates an instance of the {@link SimpleEmailPart.Builder} avoiding the * need to create one manually via {@link SimpleEmailPart#builder()}. * *

* When the {@link Consumer} completes, {@link SimpleEmailPart.Builder#build()} is called immediately and its * result is passed to {@link #htmlPart(SimpleEmailPart)}. * * @param htmlPart * a consumer that will call methods on {@link SimpleEmailPart.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #htmlPart(SimpleEmailPart) */ default Builder htmlPart(Consumer htmlPart) { return htmlPart(SimpleEmailPart.builder().applyMutation(htmlPart).build()); } /** *

* The subject line, or title, of the email. *

* * @param subject * The subject line, or title, of the email. * @return Returns a reference to this object so that method calls can be chained together. */ Builder subject(SimpleEmailPart subject); /** *

* The subject line, or title, of the email. *

* This is a convenience method that creates an instance of the {@link SimpleEmailPart.Builder} avoiding the * need to create one manually via {@link SimpleEmailPart#builder()}. * *

* When the {@link Consumer} completes, {@link SimpleEmailPart.Builder#build()} is called immediately and its * result is passed to {@link #subject(SimpleEmailPart)}. * * @param subject * a consumer that will call methods on {@link SimpleEmailPart.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #subject(SimpleEmailPart) */ default Builder subject(Consumer subject) { return subject(SimpleEmailPart.builder().applyMutation(subject).build()); } /** *

* The body of the email message, in plain text format. We recommend using plain text format for email clients * that don't render HTML content and clients that are connected to high-latency networks, such as mobile * devices. *

* * @param textPart * The body of the email message, in plain text format. We recommend using plain text format for email * clients that don't render HTML content and clients that are connected to high-latency networks, such * as mobile devices. * @return Returns a reference to this object so that method calls can be chained together. */ Builder textPart(SimpleEmailPart textPart); /** *

* The body of the email message, in plain text format. We recommend using plain text format for email clients * that don't render HTML content and clients that are connected to high-latency networks, such as mobile * devices. *

* This is a convenience method that creates an instance of the {@link SimpleEmailPart.Builder} avoiding the * need to create one manually via {@link SimpleEmailPart#builder()}. * *

* When the {@link Consumer} completes, {@link SimpleEmailPart.Builder#build()} is called immediately and its * result is passed to {@link #textPart(SimpleEmailPart)}. * * @param textPart * a consumer that will call methods on {@link SimpleEmailPart.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #textPart(SimpleEmailPart) */ default Builder textPart(Consumer textPart) { return textPart(SimpleEmailPart.builder().applyMutation(textPart).build()); } } static final class BuilderImpl implements Builder { private SimpleEmailPart htmlPart; private SimpleEmailPart subject; private SimpleEmailPart textPart; private BuilderImpl() { } private BuilderImpl(SimpleEmail model) { htmlPart(model.htmlPart); subject(model.subject); textPart(model.textPart); } public final SimpleEmailPart.Builder getHtmlPart() { return htmlPart != null ? htmlPart.toBuilder() : null; } public final void setHtmlPart(SimpleEmailPart.BuilderImpl htmlPart) { this.htmlPart = htmlPart != null ? htmlPart.build() : null; } @Override public final Builder htmlPart(SimpleEmailPart htmlPart) { this.htmlPart = htmlPart; return this; } public final SimpleEmailPart.Builder getSubject() { return subject != null ? subject.toBuilder() : null; } public final void setSubject(SimpleEmailPart.BuilderImpl subject) { this.subject = subject != null ? subject.build() : null; } @Override public final Builder subject(SimpleEmailPart subject) { this.subject = subject; return this; } public final SimpleEmailPart.Builder getTextPart() { return textPart != null ? textPart.toBuilder() : null; } public final void setTextPart(SimpleEmailPart.BuilderImpl textPart) { this.textPart = textPart != null ? textPart.build() : null; } @Override public final Builder textPart(SimpleEmailPart textPart) { this.textPart = textPart; return this; } @Override public SimpleEmail build() { return new SimpleEmail(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy