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

software.amazon.awssdk.services.connect.model.ReferenceSummary 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.connect.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
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.core.util.SdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Contains summary information about a reference. ReferenceSummary contains only one non null field * between the URL and attachment based on the reference type. *

*/ @Generated("software.amazon.awssdk:codegen") public final class ReferenceSummary implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField URL_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("Url").getter(getter(ReferenceSummary::url)).setter(setter(Builder::url)) .constructor(UrlReference::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Url").build()).build(); private static final SdkField ATTACHMENT_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("Attachment") .getter(getter(ReferenceSummary::attachment)).setter(setter(Builder::attachment)) .constructor(AttachmentReference::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Attachment").build()).build(); private static final SdkField STRING_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("String").getter(getter(ReferenceSummary::string)).setter(setter(Builder::string)) .constructor(StringReference::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("String").build()).build(); private static final SdkField NUMBER_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("Number").getter(getter(ReferenceSummary::number)).setter(setter(Builder::number)) .constructor(NumberReference::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Number").build()).build(); private static final SdkField DATE_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("Date").getter(getter(ReferenceSummary::date)).setter(setter(Builder::date)) .constructor(DateReference::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Date").build()).build(); private static final SdkField EMAIL_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("Email").getter(getter(ReferenceSummary::email)).setter(setter(Builder::email)) .constructor(EmailReference::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Email").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(URL_FIELD, ATTACHMENT_FIELD, STRING_FIELD, NUMBER_FIELD, DATE_FIELD, EMAIL_FIELD)); private static final long serialVersionUID = 1L; private final UrlReference url; private final AttachmentReference attachment; private final StringReference string; private final NumberReference number; private final DateReference date; private final EmailReference email; private final Type type; private ReferenceSummary(BuilderImpl builder) { this.url = builder.url; this.attachment = builder.attachment; this.string = builder.string; this.number = builder.number; this.date = builder.date; this.email = builder.email; this.type = builder.type; } /** *

* Information about the reference when the referenceType is URL. Otherwise, null. *

* * @return Information about the reference when the referenceType is URL. Otherwise, null. */ public final UrlReference url() { return url; } /** *

* Information about the reference when the referenceType is ATTACHMENT. Otherwise, null. *

* * @return Information about the reference when the referenceType is ATTACHMENT. * Otherwise, null. */ public final AttachmentReference attachment() { return attachment; } /** *

* Information about a reference when the referenceType is STRING. Otherwise, null. *

* * @return Information about a reference when the referenceType is STRING. Otherwise, * null. */ public final StringReference string() { return string; } /** *

* Information about a reference when the referenceType is NUMBER. Otherwise, null. *

* * @return Information about a reference when the referenceType is NUMBER. Otherwise, * null. */ public final NumberReference number() { return number; } /** *

* Information about a reference when the referenceType is DATE. Otherwise, null. *

* * @return Information about a reference when the referenceType is DATE. Otherwise, null. */ public final DateReference date() { return date; } /** *

* Information about a reference when the referenceType is EMAIL. Otherwise, null. *

* * @return Information about a reference when the referenceType is EMAIL. Otherwise, null. */ public final EmailReference email() { return email; } @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(url()); hashCode = 31 * hashCode + Objects.hashCode(attachment()); hashCode = 31 * hashCode + Objects.hashCode(string()); hashCode = 31 * hashCode + Objects.hashCode(number()); hashCode = 31 * hashCode + Objects.hashCode(date()); hashCode = 31 * hashCode + Objects.hashCode(email()); 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 ReferenceSummary)) { return false; } ReferenceSummary other = (ReferenceSummary) obj; return Objects.equals(url(), other.url()) && Objects.equals(attachment(), other.attachment()) && Objects.equals(string(), other.string()) && Objects.equals(number(), other.number()) && Objects.equals(date(), other.date()) && Objects.equals(email(), other.email()); } /** * 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("ReferenceSummary").add("Url", url()).add("Attachment", attachment()).add("String", string()) .add("Number", number()).add("Date", date()).add("Email", email()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Url": return Optional.ofNullable(clazz.cast(url())); case "Attachment": return Optional.ofNullable(clazz.cast(attachment())); case "String": return Optional.ofNullable(clazz.cast(string())); case "Number": return Optional.ofNullable(clazz.cast(number())); case "Date": return Optional.ofNullable(clazz.cast(date())); case "Email": return Optional.ofNullable(clazz.cast(email())); default: return Optional.empty(); } } /** * Create an instance of this class with {@link #url()} initialized to the given value. * *

* Information about the reference when the referenceType is URL. Otherwise, null. *

* * @param url * Information about the reference when the referenceType is URL. Otherwise, null. */ public static ReferenceSummary fromUrl(UrlReference url) { return builder().url(url).build(); } /** * Create an instance of this class with {@link #url()} initialized to the given value. * *

* Information about the reference when the referenceType is URL. Otherwise, null. *

* * @param url * Information about the reference when the referenceType is URL. Otherwise, null. */ public static ReferenceSummary fromUrl(Consumer url) { UrlReference.Builder builder = UrlReference.builder(); url.accept(builder); return fromUrl(builder.build()); } /** * Create an instance of this class with {@link #attachment()} initialized to the given value. * *

* Information about the reference when the referenceType is ATTACHMENT. Otherwise, null. *

* * @param attachment * Information about the reference when the referenceType is ATTACHMENT. Otherwise, * null. */ public static ReferenceSummary fromAttachment(AttachmentReference attachment) { return builder().attachment(attachment).build(); } /** * Create an instance of this class with {@link #attachment()} initialized to the given value. * *

* Information about the reference when the referenceType is ATTACHMENT. Otherwise, null. *

* * @param attachment * Information about the reference when the referenceType is ATTACHMENT. Otherwise, * null. */ public static ReferenceSummary fromAttachment(Consumer attachment) { AttachmentReference.Builder builder = AttachmentReference.builder(); attachment.accept(builder); return fromAttachment(builder.build()); } /** * Create an instance of this class with {@link #string()} initialized to the given value. * *

* Information about a reference when the referenceType is STRING. Otherwise, null. *

* * @param string * Information about a reference when the referenceType is STRING. Otherwise, null. */ public static ReferenceSummary fromString(StringReference string) { return builder().string(string).build(); } /** * Create an instance of this class with {@link #string()} initialized to the given value. * *

* Information about a reference when the referenceType is STRING. Otherwise, null. *

* * @param string * Information about a reference when the referenceType is STRING. Otherwise, null. */ public static ReferenceSummary fromString(Consumer string) { StringReference.Builder builder = StringReference.builder(); string.accept(builder); return fromString(builder.build()); } /** * Create an instance of this class with {@link #number()} initialized to the given value. * *

* Information about a reference when the referenceType is NUMBER. Otherwise, null. *

* * @param number * Information about a reference when the referenceType is NUMBER. Otherwise, null. */ public static ReferenceSummary fromNumber(NumberReference number) { return builder().number(number).build(); } /** * Create an instance of this class with {@link #number()} initialized to the given value. * *

* Information about a reference when the referenceType is NUMBER. Otherwise, null. *

* * @param number * Information about a reference when the referenceType is NUMBER. Otherwise, null. */ public static ReferenceSummary fromNumber(Consumer number) { NumberReference.Builder builder = NumberReference.builder(); number.accept(builder); return fromNumber(builder.build()); } /** * Create an instance of this class with {@link #date()} initialized to the given value. * *

* Information about a reference when the referenceType is DATE. Otherwise, null. *

* * @param date * Information about a reference when the referenceType is DATE. Otherwise, null. */ public static ReferenceSummary fromDate(DateReference date) { return builder().date(date).build(); } /** * Create an instance of this class with {@link #date()} initialized to the given value. * *

* Information about a reference when the referenceType is DATE. Otherwise, null. *

* * @param date * Information about a reference when the referenceType is DATE. Otherwise, null. */ public static ReferenceSummary fromDate(Consumer date) { DateReference.Builder builder = DateReference.builder(); date.accept(builder); return fromDate(builder.build()); } /** * Create an instance of this class with {@link #email()} initialized to the given value. * *

* Information about a reference when the referenceType is EMAIL. Otherwise, null. *

* * @param email * Information about a reference when the referenceType is EMAIL. Otherwise, null. */ public static ReferenceSummary fromEmail(EmailReference email) { return builder().email(email).build(); } /** * Create an instance of this class with {@link #email()} initialized to the given value. * *

* Information about a reference when the referenceType is EMAIL. Otherwise, null. *

* * @param email * Information about a reference when the referenceType is EMAIL. Otherwise, null. */ public static ReferenceSummary fromEmail(Consumer email) { EmailReference.Builder builder = EmailReference.builder(); email.accept(builder); return fromEmail(builder.build()); } /** * Retrieve an enum value representing which member of this object is populated. * * When this class is returned in a service response, this will be {@link Type#UNKNOWN_TO_SDK_VERSION} if the * service returned a member that is only known to a newer SDK version. * * When this class is created directly in your code, this will be {@link Type#UNKNOWN_TO_SDK_VERSION} if zero * members are set, and {@code null} if more than one member is set. */ public Type type() { return type; } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((ReferenceSummary) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* Information about the reference when the referenceType is URL. Otherwise, null. *

* * @param url * Information about the reference when the referenceType is URL. Otherwise, * null. * @return Returns a reference to this object so that method calls can be chained together. */ Builder url(UrlReference url); /** *

* Information about the reference when the referenceType is URL. Otherwise, null. *

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

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

* Information about the reference when the referenceType is ATTACHMENT. Otherwise, * null. *

* * @param attachment * Information about the reference when the referenceType is ATTACHMENT. * Otherwise, null. * @return Returns a reference to this object so that method calls can be chained together. */ Builder attachment(AttachmentReference attachment); /** *

* Information about the reference when the referenceType is ATTACHMENT. Otherwise, * null. *

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

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

* Information about a reference when the referenceType is STRING. Otherwise, null. *

* * @param string * Information about a reference when the referenceType is STRING. Otherwise, * null. * @return Returns a reference to this object so that method calls can be chained together. */ Builder string(StringReference string); /** *

* Information about a reference when the referenceType is STRING. Otherwise, null. *

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

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

* Information about a reference when the referenceType is NUMBER. Otherwise, null. *

* * @param number * Information about a reference when the referenceType is NUMBER. Otherwise, * null. * @return Returns a reference to this object so that method calls can be chained together. */ Builder number(NumberReference number); /** *

* Information about a reference when the referenceType is NUMBER. Otherwise, null. *

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

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

* Information about a reference when the referenceType is DATE. Otherwise, null. *

* * @param date * Information about a reference when the referenceType is DATE. Otherwise, * null. * @return Returns a reference to this object so that method calls can be chained together. */ Builder date(DateReference date); /** *

* Information about a reference when the referenceType is DATE. Otherwise, null. *

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

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

* Information about a reference when the referenceType is EMAIL. Otherwise, null. *

* * @param email * Information about a reference when the referenceType is EMAIL. Otherwise, * null. * @return Returns a reference to this object so that method calls can be chained together. */ Builder email(EmailReference email); /** *

* Information about a reference when the referenceType is EMAIL. Otherwise, null. *

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

* When the {@link Consumer} completes, {@link EmailReference.Builder#build()} is called immediately and its * result is passed to {@link #email(EmailReference)}. * * @param email * a consumer that will call methods on {@link EmailReference.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #email(EmailReference) */ default Builder email(Consumer email) { return email(EmailReference.builder().applyMutation(email).build()); } } static final class BuilderImpl implements Builder { private UrlReference url; private AttachmentReference attachment; private StringReference string; private NumberReference number; private DateReference date; private EmailReference email; private Type type = Type.UNKNOWN_TO_SDK_VERSION; private Set setTypes = EnumSet.noneOf(Type.class); private BuilderImpl() { } private BuilderImpl(ReferenceSummary model) { url(model.url); attachment(model.attachment); string(model.string); number(model.number); date(model.date); email(model.email); } public final UrlReference.Builder getUrl() { return url != null ? url.toBuilder() : null; } public final void setUrl(UrlReference.BuilderImpl url) { Object oldValue = this.url; this.url = url != null ? url.build() : null; handleUnionValueChange(Type.URL, oldValue, this.url); } @Override public final Builder url(UrlReference url) { Object oldValue = this.url; this.url = url; handleUnionValueChange(Type.URL, oldValue, this.url); return this; } public final AttachmentReference.Builder getAttachment() { return attachment != null ? attachment.toBuilder() : null; } public final void setAttachment(AttachmentReference.BuilderImpl attachment) { Object oldValue = this.attachment; this.attachment = attachment != null ? attachment.build() : null; handleUnionValueChange(Type.ATTACHMENT, oldValue, this.attachment); } @Override public final Builder attachment(AttachmentReference attachment) { Object oldValue = this.attachment; this.attachment = attachment; handleUnionValueChange(Type.ATTACHMENT, oldValue, this.attachment); return this; } public final StringReference.Builder getString() { return string != null ? string.toBuilder() : null; } public final void setString(StringReference.BuilderImpl string) { Object oldValue = this.string; this.string = string != null ? string.build() : null; handleUnionValueChange(Type.STRING, oldValue, this.string); } @Override public final Builder string(StringReference string) { Object oldValue = this.string; this.string = string; handleUnionValueChange(Type.STRING, oldValue, this.string); return this; } public final NumberReference.Builder getNumber() { return number != null ? number.toBuilder() : null; } public final void setNumber(NumberReference.BuilderImpl number) { Object oldValue = this.number; this.number = number != null ? number.build() : null; handleUnionValueChange(Type.NUMBER, oldValue, this.number); } @Override public final Builder number(NumberReference number) { Object oldValue = this.number; this.number = number; handleUnionValueChange(Type.NUMBER, oldValue, this.number); return this; } public final DateReference.Builder getDate() { return date != null ? date.toBuilder() : null; } public final void setDate(DateReference.BuilderImpl date) { Object oldValue = this.date; this.date = date != null ? date.build() : null; handleUnionValueChange(Type.DATE, oldValue, this.date); } @Override public final Builder date(DateReference date) { Object oldValue = this.date; this.date = date; handleUnionValueChange(Type.DATE, oldValue, this.date); return this; } public final EmailReference.Builder getEmail() { return email != null ? email.toBuilder() : null; } public final void setEmail(EmailReference.BuilderImpl email) { Object oldValue = this.email; this.email = email != null ? email.build() : null; handleUnionValueChange(Type.EMAIL, oldValue, this.email); } @Override public final Builder email(EmailReference email) { Object oldValue = this.email; this.email = email; handleUnionValueChange(Type.EMAIL, oldValue, this.email); return this; } @Override public ReferenceSummary build() { return new ReferenceSummary(this); } @Override public List> sdkFields() { return SDK_FIELDS; } private final void handleUnionValueChange(Type type, Object oldValue, Object newValue) { if (this.type == type || oldValue == newValue) { return; } if (newValue == null || newValue instanceof SdkAutoConstructList || newValue instanceof SdkAutoConstructMap) { setTypes.remove(type); } else if (oldValue == null || oldValue instanceof SdkAutoConstructList || oldValue instanceof SdkAutoConstructMap) { setTypes.add(type); } if (setTypes.size() == 1) { this.type = setTypes.iterator().next(); } else if (setTypes.isEmpty()) { this.type = Type.UNKNOWN_TO_SDK_VERSION; } else { this.type = null; } } } /** * @see ReferenceSummary#type() */ public enum Type { URL, ATTACHMENT, STRING, NUMBER, DATE, EMAIL, UNKNOWN_TO_SDK_VERSION } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy