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

software.amazon.awssdk.services.sns.model.PhoneNumberInformation Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon SNS module holds the client classes that are used for communicating with Amazon Simple Notification Service

There is a newer version: 2.29.39
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.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 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 getter(Function g) { return obj -> g.apply((PhoneNumberInformation) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The date and time when the phone number was created. *

* * @param createdAt * The date and time when the phone number was created. * @return Returns a reference to this object so that method calls can be chained together. */ Builder createdAt(Instant createdAt); /** *

* The phone number. *

* * @param phoneNumber * The phone number. * @return Returns a reference to this object so that method calls can be chained together. */ Builder phoneNumber(String phoneNumber); /** *

* The status of the phone number. *

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

* The two-character code for the country or region, in ISO 3166-1 alpha-2 format. *

* * @param iso2CountryCode * The two-character code for the country or region, in ISO 3166-1 alpha-2 format. * @return Returns a reference to this object so that method calls can be chained together. */ Builder iso2CountryCode(String iso2CountryCode); /** *

* The list of supported routes. *

* * @param routeType * The list of supported routes. * @see RouteType * @return Returns a reference to this object so that method calls can be chained together. * @see RouteType */ Builder routeType(String routeType); /** *

* The list of supported routes. *

* * @param routeType * The list of supported routes. * @see RouteType * @return Returns a reference to this object so that method calls can be chained together. * @see RouteType */ Builder routeType(RouteType routeType); /** *

* The capabilities of each phone number. *

* * @param numberCapabilities * The capabilities of each phone number. * @return Returns a reference to this object so that method calls can be chained together. */ Builder numberCapabilitiesWithStrings(Collection numberCapabilities); /** *

* The capabilities of each phone number. *

* * @param numberCapabilities * The capabilities of each phone number. * @return Returns a reference to this object so that method calls can be chained together. */ Builder numberCapabilitiesWithStrings(String... numberCapabilities); /** *

* The capabilities of each phone number. *

* * @param numberCapabilities * The capabilities of each phone number. * @return Returns a reference to this object so that method calls can be chained together. */ Builder numberCapabilities(Collection numberCapabilities); /** *

* The capabilities of each phone number. *

* * @param numberCapabilities * The capabilities of each phone number. * @return Returns a reference to this object so that method calls can be chained together. */ Builder numberCapabilities(NumberCapability... numberCapabilities); } static final class BuilderImpl implements Builder { private Instant createdAt; private String phoneNumber; private String status; private String iso2CountryCode; private String routeType; private List numberCapabilities = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(PhoneNumberInformation model) { createdAt(model.createdAt); phoneNumber(model.phoneNumber); status(model.status); iso2CountryCode(model.iso2CountryCode); routeType(model.routeType); numberCapabilitiesWithStrings(model.numberCapabilities); } public final Instant getCreatedAt() { return createdAt; } public final void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; } @Override public final Builder createdAt(Instant createdAt) { this.createdAt = createdAt; 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 String getStatus() { return status; } public final void setStatus(String status) { this.status = status; } @Override public final Builder status(String status) { this.status = status; return this; } public final String getIso2CountryCode() { return iso2CountryCode; } public final void setIso2CountryCode(String iso2CountryCode) { this.iso2CountryCode = iso2CountryCode; } @Override public final Builder iso2CountryCode(String iso2CountryCode) { this.iso2CountryCode = iso2CountryCode; return this; } public final String getRouteType() { return routeType; } public final void setRouteType(String routeType) { this.routeType = routeType; } @Override public final Builder routeType(String routeType) { this.routeType = routeType; return this; } @Override public final Builder routeType(RouteType routeType) { this.routeType(routeType == null ? null : routeType.toString()); return this; } public final Collection getNumberCapabilities() { if (numberCapabilities instanceof SdkAutoConstructList) { return null; } return numberCapabilities; } public final void setNumberCapabilities(Collection numberCapabilities) { this.numberCapabilities = NumberCapabilityListCopier.copy(numberCapabilities); } @Override public final Builder numberCapabilitiesWithStrings(Collection numberCapabilities) { this.numberCapabilities = NumberCapabilityListCopier.copy(numberCapabilities); return this; } @Override @SafeVarargs public final Builder numberCapabilitiesWithStrings(String... numberCapabilities) { numberCapabilitiesWithStrings(Arrays.asList(numberCapabilities)); return this; } @Override public final Builder numberCapabilities(Collection numberCapabilities) { this.numberCapabilities = NumberCapabilityListCopier.copyEnumToString(numberCapabilities); return this; } @Override @SafeVarargs public final Builder numberCapabilities(NumberCapability... numberCapabilities) { numberCapabilities(Arrays.asList(numberCapabilities)); return this; } @Override public PhoneNumberInformation build() { return new PhoneNumberInformation(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy