software.amazon.awssdk.services.sns.model.PhoneNumberInformation Maven / Gradle / Ivy
Show all versions of sns 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.sns.model;
import java.io.Serializable;
import java.time.Instant;
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.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.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 list of phone numbers and their metadata.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class PhoneNumberInformation implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField CREATED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CreatedAt").getter(getter(PhoneNumberInformation::createdAt)).setter(setter(Builder::createdAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedAt").build()).build();
private static final SdkField PHONE_NUMBER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PhoneNumber").getter(getter(PhoneNumberInformation::phoneNumber)).setter(setter(Builder::phoneNumber))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PhoneNumber").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(PhoneNumberInformation::status)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField ISO2_COUNTRY_CODE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Iso2CountryCode").getter(getter(PhoneNumberInformation::iso2CountryCode))
.setter(setter(Builder::iso2CountryCode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Iso2CountryCode").build()).build();
private static final SdkField ROUTE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RouteType").getter(getter(PhoneNumberInformation::routeTypeAsString)).setter(setter(Builder::routeType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RouteType").build()).build();
private static final SdkField> NUMBER_CAPABILITIES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("NumberCapabilities")
.getter(getter(PhoneNumberInformation::numberCapabilitiesAsStrings))
.setter(setter(Builder::numberCapabilitiesWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NumberCapabilities").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CREATED_AT_FIELD,
PHONE_NUMBER_FIELD, STATUS_FIELD, ISO2_COUNTRY_CODE_FIELD, ROUTE_TYPE_FIELD, NUMBER_CAPABILITIES_FIELD));
private static final long serialVersionUID = 1L;
private final Instant createdAt;
private final String phoneNumber;
private final String status;
private final String iso2CountryCode;
private final String routeType;
private final List numberCapabilities;
private PhoneNumberInformation(BuilderImpl builder) {
this.createdAt = builder.createdAt;
this.phoneNumber = builder.phoneNumber;
this.status = builder.status;
this.iso2CountryCode = builder.iso2CountryCode;
this.routeType = builder.routeType;
this.numberCapabilities = builder.numberCapabilities;
}
/**
*
* The date and time when the phone number was created.
*
*
* @return The date and time when the phone number was created.
*/
public final Instant createdAt() {
return createdAt;
}
/**
*
* The phone number.
*
*
* @return The phone number.
*/
public final String phoneNumber() {
return phoneNumber;
}
/**
*
* The status of the phone number.
*
*
* @return The status of the phone number.
*/
public final String status() {
return status;
}
/**
*
* The two-character code for the country or region, in ISO 3166-1 alpha-2 format.
*
*
* @return The two-character code for the country or region, in ISO 3166-1 alpha-2 format.
*/
public final String iso2CountryCode() {
return iso2CountryCode;
}
/**
*
* The list of supported routes.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #routeType} will
* return {@link RouteType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #routeTypeAsString}.
*
*
* @return The list of supported routes.
* @see RouteType
*/
public final RouteType routeType() {
return RouteType.fromValue(routeType);
}
/**
*
* The list of supported routes.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #routeType} will
* return {@link RouteType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #routeTypeAsString}.
*
*
* @return The list of supported routes.
* @see RouteType
*/
public final String routeTypeAsString() {
return routeType;
}
/**
*
* The capabilities of each phone number.
*
*
* 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 #hasNumberCapabilities} method.
*
*
* @return The capabilities of each phone number.
*/
public final List numberCapabilities() {
return NumberCapabilityListCopier.copyStringToEnum(numberCapabilities);
}
/**
* For responses, this returns true if the service returned a value for the NumberCapabilities 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 hasNumberCapabilities() {
return numberCapabilities != null && !(numberCapabilities instanceof SdkAutoConstructList);
}
/**
*
* The capabilities of each phone number.
*
*
* 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 #hasNumberCapabilities} method.
*
*
* @return The capabilities of each phone number.
*/
public final List numberCapabilitiesAsStrings() {
return numberCapabilities;
}
@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(createdAt());
hashCode = 31 * hashCode + Objects.hashCode(phoneNumber());
hashCode = 31 * hashCode + Objects.hashCode(status());
hashCode = 31 * hashCode + Objects.hashCode(iso2CountryCode());
hashCode = 31 * hashCode + Objects.hashCode(routeTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasNumberCapabilities() ? numberCapabilitiesAsStrings() : 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 PhoneNumberInformation)) {
return false;
}
PhoneNumberInformation other = (PhoneNumberInformation) obj;
return Objects.equals(createdAt(), other.createdAt()) && Objects.equals(phoneNumber(), other.phoneNumber())
&& Objects.equals(status(), other.status()) && Objects.equals(iso2CountryCode(), other.iso2CountryCode())
&& Objects.equals(routeTypeAsString(), other.routeTypeAsString())
&& hasNumberCapabilities() == other.hasNumberCapabilities()
&& Objects.equals(numberCapabilitiesAsStrings(), other.numberCapabilitiesAsStrings());
}
/**
* 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("PhoneNumberInformation").add("CreatedAt", createdAt())
.add("PhoneNumber", phoneNumber() == null ? null : "*** Sensitive Data Redacted ***").add("Status", status())
.add("Iso2CountryCode", iso2CountryCode()).add("RouteType", routeTypeAsString())
.add("NumberCapabilities", hasNumberCapabilities() ? numberCapabilitiesAsStrings() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "CreatedAt":
return Optional.ofNullable(clazz.cast(createdAt()));
case "PhoneNumber":
return Optional.ofNullable(clazz.cast(phoneNumber()));
case "Status":
return Optional.ofNullable(clazz.cast(status()));
case "Iso2CountryCode":
return Optional.ofNullable(clazz.cast(iso2CountryCode()));
case "RouteType":
return Optional.ofNullable(clazz.cast(routeTypeAsString()));
case "NumberCapabilities":
return Optional.ofNullable(clazz.cast(numberCapabilitiesAsStrings()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function