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

software.amazon.awssdk.services.pinpoint.model.EndpointLocation Maven / Gradle / Ivy

/*
 * Copyright 2014-2019 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.pinpoint.model;

import java.io.Serializable;
import java.util.Arrays;
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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * Location data for the endpoint.
 */
@Generated("software.amazon.awssdk:codegen")
public final class EndpointLocation implements SdkPojo, Serializable,
        ToCopyableBuilder {
    private static final SdkField CITY_FIELD = SdkField. builder(MarshallingType.STRING)
            .getter(getter(EndpointLocation::city)).setter(setter(Builder::city))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("City").build()).build();

    private static final SdkField COUNTRY_FIELD = SdkField. builder(MarshallingType.STRING)
            .getter(getter(EndpointLocation::country)).setter(setter(Builder::country))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Country").build()).build();

    private static final SdkField LATITUDE_FIELD = SdkField. builder(MarshallingType.DOUBLE)
            .getter(getter(EndpointLocation::latitude)).setter(setter(Builder::latitude))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Latitude").build()).build();

    private static final SdkField LONGITUDE_FIELD = SdkField. builder(MarshallingType.DOUBLE)
            .getter(getter(EndpointLocation::longitude)).setter(setter(Builder::longitude))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Longitude").build()).build();

    private static final SdkField POSTAL_CODE_FIELD = SdkField. builder(MarshallingType.STRING)
            .getter(getter(EndpointLocation::postalCode)).setter(setter(Builder::postalCode))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PostalCode").build()).build();

    private static final SdkField REGION_FIELD = SdkField. builder(MarshallingType.STRING)
            .getter(getter(EndpointLocation::region)).setter(setter(Builder::region))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Region").build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CITY_FIELD, COUNTRY_FIELD,
            LATITUDE_FIELD, LONGITUDE_FIELD, POSTAL_CODE_FIELD, REGION_FIELD));

    private static final long serialVersionUID = 1L;

    private final String city;

    private final String country;

    private final Double latitude;

    private final Double longitude;

    private final String postalCode;

    private final String region;

    private EndpointLocation(BuilderImpl builder) {
        this.city = builder.city;
        this.country = builder.country;
        this.latitude = builder.latitude;
        this.longitude = builder.longitude;
        this.postalCode = builder.postalCode;
        this.region = builder.region;
    }

    /**
     * The city where the endpoint is located.
     * 
     * @return The city where the endpoint is located.
     */
    public String city() {
        return city;
    }

    /**
     * The two-letter code for the country or region of the endpoint. Specified as an ISO 3166-1 alpha-2 code, such as
     * "US" for the United States.
     * 
     * @return The two-letter code for the country or region of the endpoint. Specified as an ISO 3166-1 alpha-2 code,
     *         such as "US" for the United States.
     */
    public String country() {
        return country;
    }

    /**
     * The latitude of the endpoint location, rounded to one decimal place.
     * 
     * @return The latitude of the endpoint location, rounded to one decimal place.
     */
    public Double latitude() {
        return latitude;
    }

    /**
     * The longitude of the endpoint location, rounded to one decimal place.
     * 
     * @return The longitude of the endpoint location, rounded to one decimal place.
     */
    public Double longitude() {
        return longitude;
    }

    /**
     * The postal code or zip code of the endpoint.
     * 
     * @return The postal code or zip code of the endpoint.
     */
    public String postalCode() {
        return postalCode;
    }

    /**
     * The region of the endpoint location. For example, in the United States, this corresponds to a state.
     * 
     * @return The region of the endpoint location. For example, in the United States, this corresponds to a state.
     */
    public String region() {
        return region;
    }

    @Override
    public Builder toBuilder() {
        return new BuilderImpl(this);
    }

    public static Builder builder() {
        return new BuilderImpl();
    }

    public static Class serializableBuilderClass() {
        return BuilderImpl.class;
    }

    @Override
    public int hashCode() {
        int hashCode = 1;
        hashCode = 31 * hashCode + Objects.hashCode(city());
        hashCode = 31 * hashCode + Objects.hashCode(country());
        hashCode = 31 * hashCode + Objects.hashCode(latitude());
        hashCode = 31 * hashCode + Objects.hashCode(longitude());
        hashCode = 31 * hashCode + Objects.hashCode(postalCode());
        hashCode = 31 * hashCode + Objects.hashCode(region());
        return hashCode;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof EndpointLocation)) {
            return false;
        }
        EndpointLocation other = (EndpointLocation) obj;
        return Objects.equals(city(), other.city()) && Objects.equals(country(), other.country())
                && Objects.equals(latitude(), other.latitude()) && Objects.equals(longitude(), other.longitude())
                && Objects.equals(postalCode(), other.postalCode()) && Objects.equals(region(), other.region());
    }

    /**
     * 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 String toString() {
        return ToString.builder("EndpointLocation").add("City", city()).add("Country", country()).add("Latitude", latitude())
                .add("Longitude", longitude()).add("PostalCode", postalCode()).add("Region", region()).build();
    }

    public  Optional getValueForField(String fieldName, Class clazz) {
        switch (fieldName) {
        case "City":
            return Optional.ofNullable(clazz.cast(city()));
        case "Country":
            return Optional.ofNullable(clazz.cast(country()));
        case "Latitude":
            return Optional.ofNullable(clazz.cast(latitude()));
        case "Longitude":
            return Optional.ofNullable(clazz.cast(longitude()));
        case "PostalCode":
            return Optional.ofNullable(clazz.cast(postalCode()));
        case "Region":
            return Optional.ofNullable(clazz.cast(region()));
        default:
            return Optional.empty();
        }
    }

    @Override
    public List> sdkFields() {
        return SDK_FIELDS;
    }

    private static  Function getter(Function g) {
        return obj -> g.apply((EndpointLocation) obj);
    }

    private static  BiConsumer setter(BiConsumer s) {
        return (obj, val) -> s.accept((Builder) obj, val);
    }

    public interface Builder extends SdkPojo, CopyableBuilder {
        /**
         * The city where the endpoint is located.
         * 
         * @param city
         *        The city where the endpoint is located.
         * @return Returns a reference to this object so that method calls can be chained together.
         */
        Builder city(String city);

        /**
         * The two-letter code for the country or region of the endpoint. Specified as an ISO 3166-1 alpha-2 code, such
         * as "US" for the United States.
         * 
         * @param country
         *        The two-letter code for the country or region of the endpoint. Specified as an ISO 3166-1 alpha-2
         *        code, such as "US" for the United States.
         * @return Returns a reference to this object so that method calls can be chained together.
         */
        Builder country(String country);

        /**
         * The latitude of the endpoint location, rounded to one decimal place.
         * 
         * @param latitude
         *        The latitude of the endpoint location, rounded to one decimal place.
         * @return Returns a reference to this object so that method calls can be chained together.
         */
        Builder latitude(Double latitude);

        /**
         * The longitude of the endpoint location, rounded to one decimal place.
         * 
         * @param longitude
         *        The longitude of the endpoint location, rounded to one decimal place.
         * @return Returns a reference to this object so that method calls can be chained together.
         */
        Builder longitude(Double longitude);

        /**
         * The postal code or zip code of the endpoint.
         * 
         * @param postalCode
         *        The postal code or zip code of the endpoint.
         * @return Returns a reference to this object so that method calls can be chained together.
         */
        Builder postalCode(String postalCode);

        /**
         * The region of the endpoint location. For example, in the United States, this corresponds to a state.
         * 
         * @param region
         *        The region of the endpoint location. For example, in the United States, this corresponds to a state.
         * @return Returns a reference to this object so that method calls can be chained together.
         */
        Builder region(String region);
    }

    static final class BuilderImpl implements Builder {
        private String city;

        private String country;

        private Double latitude;

        private Double longitude;

        private String postalCode;

        private String region;

        private BuilderImpl() {
        }

        private BuilderImpl(EndpointLocation model) {
            city(model.city);
            country(model.country);
            latitude(model.latitude);
            longitude(model.longitude);
            postalCode(model.postalCode);
            region(model.region);
        }

        public final String getCity() {
            return city;
        }

        @Override
        public final Builder city(String city) {
            this.city = city;
            return this;
        }

        public final void setCity(String city) {
            this.city = city;
        }

        public final String getCountry() {
            return country;
        }

        @Override
        public final Builder country(String country) {
            this.country = country;
            return this;
        }

        public final void setCountry(String country) {
            this.country = country;
        }

        public final Double getLatitude() {
            return latitude;
        }

        @Override
        public final Builder latitude(Double latitude) {
            this.latitude = latitude;
            return this;
        }

        public final void setLatitude(Double latitude) {
            this.latitude = latitude;
        }

        public final Double getLongitude() {
            return longitude;
        }

        @Override
        public final Builder longitude(Double longitude) {
            this.longitude = longitude;
            return this;
        }

        public final void setLongitude(Double longitude) {
            this.longitude = longitude;
        }

        public final String getPostalCode() {
            return postalCode;
        }

        @Override
        public final Builder postalCode(String postalCode) {
            this.postalCode = postalCode;
            return this;
        }

        public final void setPostalCode(String postalCode) {
            this.postalCode = postalCode;
        }

        public final String getRegion() {
            return region;
        }

        @Override
        public final Builder region(String region) {
            this.region = region;
            return this;
        }

        public final void setRegion(String region) {
            this.region = region;
        }

        @Override
        public EndpointLocation build() {
            return new EndpointLocation(this);
        }

        @Override
        public List> sdkFields() {
            return SDK_FIELDS;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy