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

com.myperfit.sdk.transactional.domain.MailContentRequest Maven / Gradle / Ivy

There is a newer version: 1.1.8
Show newest version
package com.myperfit.sdk.transactional.domain;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.Objects;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;

/**
 * Immutable implementation of {@link AbstractMailContentRequest}.
 * 

* Use the builder to create immutable instances: * {@code MailContentRequest.builder()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Immutable public final class MailContentRequest extends AbstractMailContentRequest { private final @Nullable String html; private final @Nullable String text; private MailContentRequest(@Nullable String html, @Nullable String text) { this.html = html; this.text = text; } /** * @return The value of the {@code html} attribute */ @JsonProperty("html") @Override public @Nullable String html() { return html; } /** * @return The value of the {@code text} attribute */ @JsonProperty("text") @Override public @Nullable String text() { return text; } /** * Copy the current immutable object by setting a value for the {@link AbstractMailContentRequest#html() html} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for html (can be {@code null}) * @return A modified copy of the {@code this} object */ public final MailContentRequest withHtml(@Nullable String value) { if (Objects.equals(this.html, value)) return this; return new MailContentRequest(value, this.text); } /** * Copy the current immutable object by setting a value for the {@link AbstractMailContentRequest#text() text} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for text (can be {@code null}) * @return A modified copy of the {@code this} object */ public final MailContentRequest withText(@Nullable String value) { if (Objects.equals(this.text, value)) return this; return new MailContentRequest(this.html, value); } /** * This instance is equal to all instances of {@code MailContentRequest} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@Nullable Object another) { if (this == another) return true; return another instanceof MailContentRequest && equalTo((MailContentRequest) another); } private boolean equalTo(MailContentRequest another) { return Objects.equals(html, another.html) && Objects.equals(text, another.text); } /** * Computes a hash code from attributes: {@code html}, {@code text}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + Objects.hashCode(html); h += (h << 5) + Objects.hashCode(text); return h; } /** * Prints the immutable value {@code MailContentRequest} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "MailContentRequest{" + "html=" + html + ", text=" + text + "}"; } /** * Utility type used to correctly read immutable object from JSON representation. * @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure */ @Deprecated @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json extends AbstractMailContentRequest { @Nullable String html; @Nullable String text; @JsonProperty("html") public void setHtml(@Nullable String html) { this.html = html; } @JsonProperty("text") public void setText(@Nullable String text) { this.text = text; } @Override public String html() { throw new UnsupportedOperationException(); } @Override public String text() { throw new UnsupportedOperationException(); } } /** * @param json A JSON-bindable data structure * @return An immutable value type * @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure */ @Deprecated @JsonCreator(mode = JsonCreator.Mode.DELEGATING) static MailContentRequest fromJson(Json json) { MailContentRequest.Builder builder = MailContentRequest.builder(); if (json.html != null) { builder.html(json.html); } if (json.text != null) { builder.text(json.text); } return builder.build(); } /** * Creates an immutable copy of a {@link AbstractMailContentRequest} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable MailContentRequest instance */ public static MailContentRequest copyOf(AbstractMailContentRequest instance) { if (instance instanceof MailContentRequest) { return (MailContentRequest) instance; } return MailContentRequest.builder() .from(instance) .build(); } /** * Creates a builder for {@link MailContentRequest MailContentRequest}. * @return A new MailContentRequest builder */ public static MailContentRequest.Builder builder() { return new MailContentRequest.Builder(); } /** * Builds instances of type {@link MailContentRequest MailContentRequest}. * Initialize attributes and then invoke the {@link #build()} method to create an * immutable instance. *

{@code Builder} is not thread-safe and generally should not be stored in a field or collection, * but instead used immediately to create instances. */ @NotThreadSafe public static final class Builder { private @Nullable String html; private @Nullable String text; private Builder() { } /** * Fill a builder with attribute values from the provided {@code AbstractMailContentRequest} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(AbstractMailContentRequest instance) { Objects.requireNonNull(instance, "instance"); @Nullable String htmlValue = instance.html(); if (htmlValue != null) { html(htmlValue); } @Nullable String textValue = instance.text(); if (textValue != null) { text(textValue); } return this; } /** * Initializes the value for the {@link AbstractMailContentRequest#html() html} attribute. * @param html The value for html (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("html") public final Builder html(@Nullable String html) { this.html = html; return this; } /** * Initializes the value for the {@link AbstractMailContentRequest#text() text} attribute. * @param text The value for text (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("text") public final Builder text(@Nullable String text) { this.text = text; return this; } /** * Builds a new {@link MailContentRequest MailContentRequest}. * @return An immutable instance of MailContentRequest * @throws java.lang.IllegalStateException if any required attributes are missing */ public MailContentRequest build() { return new MailContentRequest(html, text); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy