software.amazon.awssdk.services.alexaforbusiness.model.ContactData Maven / Gradle / Ivy
Show all versions of alexaforbusiness Show documentation
/*
* 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;
/**
*
* Information related to a contact.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ContactData implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField CONTACT_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ContactArn").getter(getter(ContactData::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(ContactData::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(ContactData::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(ContactData::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(ContactData::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(ContactData::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(ContactData::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 ContactData(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 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 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 extends Builder> 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 ContactData)) {
return false;
}
ContactData other = (ContactData) 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("ContactData").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