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

software.amazon.awssdk.services.alexaforbusiness.model.Contact Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Alexa For Business module holds the client classes that are used for communicating with Alexa For Business Service

There is a newer version: 2.25.61
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.alexaforbusiness.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
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 java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* A contact with attributes. *

*/ @Generated("software.amazon.awssdk:codegen") public final class Contact implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField CONTACT_ARN_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("ContactArn").getter(getter(Contact::contactArn)).setter(setter(Builder::contactArn)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ContactArn").build()).build(); private static final SdkField DISPLAY_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("DisplayName").getter(getter(Contact::displayName)).setter(setter(Builder::displayName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DisplayName").build()).build(); private static final SdkField FIRST_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("FirstName").getter(getter(Contact::firstName)).setter(setter(Builder::firstName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FirstName").build()).build(); private static final SdkField LAST_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("LastName").getter(getter(Contact::lastName)).setter(setter(Builder::lastName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastName").build()).build(); private static final SdkField PHONE_NUMBER_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("PhoneNumber").getter(getter(Contact::phoneNumber)).setter(setter(Builder::phoneNumber)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PhoneNumber").build()).build(); private static final SdkField> PHONE_NUMBERS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("PhoneNumbers") .getter(getter(Contact::phoneNumbers)) .setter(setter(Builder::phoneNumbers)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PhoneNumbers").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(PhoneNumber::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField> SIP_ADDRESSES_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("SipAddresses") .getter(getter(Contact::sipAddresses)) .setter(setter(Builder::sipAddresses)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SipAddresses").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(SipAddress::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CONTACT_ARN_FIELD, DISPLAY_NAME_FIELD, FIRST_NAME_FIELD, LAST_NAME_FIELD, PHONE_NUMBER_FIELD, PHONE_NUMBERS_FIELD, SIP_ADDRESSES_FIELD)); private static final long serialVersionUID = 1L; private final String contactArn; private final String displayName; private final String firstName; private final String lastName; private final String phoneNumber; private final List phoneNumbers; private final List sipAddresses; private Contact(BuilderImpl builder) { this.contactArn = builder.contactArn; this.displayName = builder.displayName; this.firstName = builder.firstName; this.lastName = builder.lastName; this.phoneNumber = builder.phoneNumber; this.phoneNumbers = builder.phoneNumbers; this.sipAddresses = builder.sipAddresses; } /** *

* The ARN of the contact. *

* * @return The ARN of the contact. */ public final String contactArn() { return contactArn; } /** *

* The name of the contact to display on the console. *

* * @return The name of the contact to display on the console. */ public final String displayName() { return displayName; } /** *

* The first name of the contact, used to call the contact on the device. *

* * @return The first name of the contact, used to call the contact on the device. */ public final String firstName() { return firstName; } /** *

* The last name of the contact, used to call the contact on the device. *

* * @return The last name of the contact, used to call the contact on the device. */ public final String lastName() { return lastName; } /** *

* The phone number of the contact. The phone number type defaults to WORK. You can either specify PhoneNumber or * PhoneNumbers. We recommend that you use PhoneNumbers, which lets you specify the phone number type and multiple * numbers. *

* * @return The phone number of the contact. The phone number type defaults to WORK. You can either specify * PhoneNumber or PhoneNumbers. We recommend that you use PhoneNumbers, which lets you specify the phone * number type and multiple numbers. */ public final String phoneNumber() { return phoneNumber; } /** * For responses, this returns true if the service returned a value for the PhoneNumbers property. This DOES NOT * check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). * This is useful because the SDK will never return a null collection or map, but you may need to differentiate * between the service returning nothing (or null) and the service returning an empty collection or map. For * requests, this returns true if a value for the property was specified in the request builder, and false if a * value was not specified. */ public final boolean hasPhoneNumbers() { return phoneNumbers != null && !(phoneNumbers instanceof SdkAutoConstructList); } /** *

* The list of phone numbers for the contact. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasPhoneNumbers} method. *

* * @return The list of phone numbers for the contact. */ public final List phoneNumbers() { return phoneNumbers; } /** * For responses, this returns true if the service returned a value for the SipAddresses property. This DOES NOT * check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). * This is useful because the SDK will never return a null collection or map, but you may need to differentiate * between the service returning nothing (or null) and the service returning an empty collection or map. For * requests, this returns true if a value for the property was specified in the request builder, and false if a * value was not specified. */ public final boolean hasSipAddresses() { return sipAddresses != null && !(sipAddresses instanceof SdkAutoConstructList); } /** *

* The list of SIP addresses for the contact. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasSipAddresses} method. *

* * @return The list of SIP addresses for the contact. */ public final List sipAddresses() { return sipAddresses; } @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(contactArn()); hashCode = 31 * hashCode + Objects.hashCode(displayName()); hashCode = 31 * hashCode + Objects.hashCode(firstName()); hashCode = 31 * hashCode + Objects.hashCode(lastName()); hashCode = 31 * hashCode + Objects.hashCode(phoneNumber()); hashCode = 31 * hashCode + Objects.hashCode(hasPhoneNumbers() ? phoneNumbers() : null); hashCode = 31 * hashCode + Objects.hashCode(hasSipAddresses() ? sipAddresses() : null); 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 Contact)) { return false; } Contact other = (Contact) obj; return Objects.equals(contactArn(), other.contactArn()) && Objects.equals(displayName(), other.displayName()) && Objects.equals(firstName(), other.firstName()) && Objects.equals(lastName(), other.lastName()) && Objects.equals(phoneNumber(), other.phoneNumber()) && hasPhoneNumbers() == other.hasPhoneNumbers() && Objects.equals(phoneNumbers(), other.phoneNumbers()) && hasSipAddresses() == other.hasSipAddresses() && Objects.equals(sipAddresses(), other.sipAddresses()); } /** * 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("Contact").add("ContactArn", contactArn()).add("DisplayName", displayName()) .add("FirstName", firstName()).add("LastName", lastName()) .add("PhoneNumber", phoneNumber() == null ? null : "*** Sensitive Data Redacted ***") .add("PhoneNumbers", hasPhoneNumbers() ? phoneNumbers() : null) .add("SipAddresses", hasSipAddresses() ? sipAddresses() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "ContactArn": return Optional.ofNullable(clazz.cast(contactArn())); case "DisplayName": return Optional.ofNullable(clazz.cast(displayName())); case "FirstName": return Optional.ofNullable(clazz.cast(firstName())); case "LastName": return Optional.ofNullable(clazz.cast(lastName())); case "PhoneNumber": return Optional.ofNullable(clazz.cast(phoneNumber())); case "PhoneNumbers": return Optional.ofNullable(clazz.cast(phoneNumbers())); case "SipAddresses": return Optional.ofNullable(clazz.cast(sipAddresses())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((Contact) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The ARN of the contact. *

* * @param contactArn * The ARN of the contact. * @return Returns a reference to this object so that method calls can be chained together. */ Builder contactArn(String contactArn); /** *

* The name of the contact to display on the console. *

* * @param displayName * The name of the contact to display on the console. * @return Returns a reference to this object so that method calls can be chained together. */ Builder displayName(String displayName); /** *

* The first name of the contact, used to call the contact on the device. *

* * @param firstName * The first name of the contact, used to call the contact on the device. * @return Returns a reference to this object so that method calls can be chained together. */ Builder firstName(String firstName); /** *

* The last name of the contact, used to call the contact on the device. *

* * @param lastName * The last name of the contact, used to call the contact on the device. * @return Returns a reference to this object so that method calls can be chained together. */ Builder lastName(String lastName); /** *

* The phone number of the contact. The phone number type defaults to WORK. You can either specify PhoneNumber * or PhoneNumbers. We recommend that you use PhoneNumbers, which lets you specify the phone number type and * multiple numbers. *

* * @param phoneNumber * The phone number of the contact. The phone number type defaults to WORK. You can either specify * PhoneNumber or PhoneNumbers. We recommend that you use PhoneNumbers, which lets you specify the phone * number type and multiple numbers. * @return Returns a reference to this object so that method calls can be chained together. */ Builder phoneNumber(String phoneNumber); /** *

* The list of phone numbers for the contact. *

* * @param phoneNumbers * The list of phone numbers for the contact. * @return Returns a reference to this object so that method calls can be chained together. */ Builder phoneNumbers(Collection phoneNumbers); /** *

* The list of phone numbers for the contact. *

* * @param phoneNumbers * The list of phone numbers for the contact. * @return Returns a reference to this object so that method calls can be chained together. */ Builder phoneNumbers(PhoneNumber... phoneNumbers); /** *

* The list of phone numbers for the contact. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.alexaforbusiness.model.PhoneNumber.Builder} avoiding the need to * create one manually via {@link software.amazon.awssdk.services.alexaforbusiness.model.PhoneNumber#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.alexaforbusiness.model.PhoneNumber.Builder#build()} is called * immediately and its result is passed to {@link #phoneNumbers(List)}. * * @param phoneNumbers * a consumer that will call methods on * {@link software.amazon.awssdk.services.alexaforbusiness.model.PhoneNumber.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #phoneNumbers(java.util.Collection) */ Builder phoneNumbers(Consumer... phoneNumbers); /** *

* The list of SIP addresses for the contact. *

* * @param sipAddresses * The list of SIP addresses for the contact. * @return Returns a reference to this object so that method calls can be chained together. */ Builder sipAddresses(Collection sipAddresses); /** *

* The list of SIP addresses for the contact. *

* * @param sipAddresses * The list of SIP addresses for the contact. * @return Returns a reference to this object so that method calls can be chained together. */ Builder sipAddresses(SipAddress... sipAddresses); /** *

* The list of SIP addresses for the contact. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.alexaforbusiness.model.SipAddress.Builder} avoiding the need to create * one manually via {@link software.amazon.awssdk.services.alexaforbusiness.model.SipAddress#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.alexaforbusiness.model.SipAddress.Builder#build()} is called * immediately and its result is passed to {@link #sipAddresses(List)}. * * @param sipAddresses * a consumer that will call methods on * {@link software.amazon.awssdk.services.alexaforbusiness.model.SipAddress.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #sipAddresses(java.util.Collection) */ Builder sipAddresses(Consumer... sipAddresses); } static final class BuilderImpl implements Builder { private String contactArn; private String displayName; private String firstName; private String lastName; private String phoneNumber; private List phoneNumbers = DefaultSdkAutoConstructList.getInstance(); private List sipAddresses = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(Contact model) { contactArn(model.contactArn); displayName(model.displayName); firstName(model.firstName); lastName(model.lastName); phoneNumber(model.phoneNumber); phoneNumbers(model.phoneNumbers); sipAddresses(model.sipAddresses); } public final String getContactArn() { return contactArn; } public final void setContactArn(String contactArn) { this.contactArn = contactArn; } @Override public final Builder contactArn(String contactArn) { this.contactArn = contactArn; return this; } public final String getDisplayName() { return displayName; } public final void setDisplayName(String displayName) { this.displayName = displayName; } @Override public final Builder displayName(String displayName) { this.displayName = displayName; return this; } public final String getFirstName() { return firstName; } public final void setFirstName(String firstName) { this.firstName = firstName; } @Override public final Builder firstName(String firstName) { this.firstName = firstName; return this; } public final String getLastName() { return lastName; } public final void setLastName(String lastName) { this.lastName = lastName; } @Override public final Builder lastName(String lastName) { this.lastName = lastName; return this; } public final String getPhoneNumber() { return phoneNumber; } public final void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } @Override public final Builder phoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; return this; } public final List getPhoneNumbers() { List result = PhoneNumberListCopier.copyToBuilder(this.phoneNumbers); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setPhoneNumbers(Collection phoneNumbers) { this.phoneNumbers = PhoneNumberListCopier.copyFromBuilder(phoneNumbers); } @Override public final Builder phoneNumbers(Collection phoneNumbers) { this.phoneNumbers = PhoneNumberListCopier.copy(phoneNumbers); return this; } @Override @SafeVarargs public final Builder phoneNumbers(PhoneNumber... phoneNumbers) { phoneNumbers(Arrays.asList(phoneNumbers)); return this; } @Override @SafeVarargs public final Builder phoneNumbers(Consumer... phoneNumbers) { phoneNumbers(Stream.of(phoneNumbers).map(c -> PhoneNumber.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final List getSipAddresses() { List result = SipAddressListCopier.copyToBuilder(this.sipAddresses); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setSipAddresses(Collection sipAddresses) { this.sipAddresses = SipAddressListCopier.copyFromBuilder(sipAddresses); } @Override public final Builder sipAddresses(Collection sipAddresses) { this.sipAddresses = SipAddressListCopier.copy(sipAddresses); return this; } @Override @SafeVarargs public final Builder sipAddresses(SipAddress... sipAddresses) { sipAddresses(Arrays.asList(sipAddresses)); return this; } @Override @SafeVarargs public final Builder sipAddresses(Consumer... sipAddresses) { sipAddresses(Stream.of(sipAddresses).map(c -> SipAddress.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } @Override public Contact build() { return new Contact(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy