
software.amazon.awssdk.services.location.model.Place Maven / Gradle / Ivy
/*
* 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.location.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.Consumer;
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;
/**
*
* Contains details about addresses or points of interest that match the search criteria.
*
*
* Not all details are included with all responses. Some details may only be returned by specific data partners.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Place implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ADDRESS_NUMBER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AddressNumber").getter(getter(Place::addressNumber)).setter(setter(Builder::addressNumber))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AddressNumber").build()).build();
private static final SdkField COUNTRY_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Country")
.getter(getter(Place::country)).setter(setter(Builder::country))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Country").build()).build();
private static final SdkField GEOMETRY_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Geometry").getter(getter(Place::geometry)).setter(setter(Builder::geometry))
.constructor(PlaceGeometry::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Geometry").build()).build();
private static final SdkField INTERPOLATED_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("Interpolated").getter(getter(Place::interpolated)).setter(setter(Builder::interpolated))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Interpolated").build()).build();
private static final SdkField LABEL_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Label")
.getter(getter(Place::label)).setter(setter(Builder::label))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Label").build()).build();
private static final SdkField MUNICIPALITY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Municipality").getter(getter(Place::municipality)).setter(setter(Builder::municipality))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Municipality").build()).build();
private static final SdkField NEIGHBORHOOD_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Neighborhood").getter(getter(Place::neighborhood)).setter(setter(Builder::neighborhood))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Neighborhood").build()).build();
private static final SdkField POSTAL_CODE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PostalCode").getter(getter(Place::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).memberName("Region")
.getter(getter(Place::region)).setter(setter(Builder::region))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Region").build()).build();
private static final SdkField STREET_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Street")
.getter(getter(Place::street)).setter(setter(Builder::street))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Street").build()).build();
private static final SdkField SUB_REGION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SubRegion").getter(getter(Place::subRegion)).setter(setter(Builder::subRegion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SubRegion").build()).build();
private static final SdkField TIME_ZONE_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("TimeZone").getter(getter(Place::timeZone)).setter(setter(Builder::timeZone))
.constructor(TimeZone::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TimeZone").build()).build();
private static final SdkField UNIT_NUMBER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("UnitNumber").getter(getter(Place::unitNumber)).setter(setter(Builder::unitNumber))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UnitNumber").build()).build();
private static final SdkField UNIT_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("UnitType").getter(getter(Place::unitType)).setter(setter(Builder::unitType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UnitType").build()).build();
private static final List> SDK_FIELDS = Collections
.unmodifiableList(Arrays.asList(ADDRESS_NUMBER_FIELD, COUNTRY_FIELD, GEOMETRY_FIELD, INTERPOLATED_FIELD, LABEL_FIELD,
MUNICIPALITY_FIELD, NEIGHBORHOOD_FIELD, POSTAL_CODE_FIELD, REGION_FIELD, STREET_FIELD, SUB_REGION_FIELD,
TIME_ZONE_FIELD, UNIT_NUMBER_FIELD, UNIT_TYPE_FIELD));
private static final long serialVersionUID = 1L;
private final String addressNumber;
private final String country;
private final PlaceGeometry geometry;
private final Boolean interpolated;
private final String label;
private final String municipality;
private final String neighborhood;
private final String postalCode;
private final String region;
private final String street;
private final String subRegion;
private final TimeZone timeZone;
private final String unitNumber;
private final String unitType;
private Place(BuilderImpl builder) {
this.addressNumber = builder.addressNumber;
this.country = builder.country;
this.geometry = builder.geometry;
this.interpolated = builder.interpolated;
this.label = builder.label;
this.municipality = builder.municipality;
this.neighborhood = builder.neighborhood;
this.postalCode = builder.postalCode;
this.region = builder.region;
this.street = builder.street;
this.subRegion = builder.subRegion;
this.timeZone = builder.timeZone;
this.unitNumber = builder.unitNumber;
this.unitType = builder.unitType;
}
/**
*
* The numerical portion of an address, such as a building number.
*
*
* @return The numerical portion of an address, such as a building number.
*/
public final String addressNumber() {
return addressNumber;
}
/**
*
* A country/region specified using ISO 3166 3-digit
* country/region code. For example, CAN
.
*
*
* @return A country/region specified using ISO 3166
* 3-digit country/region code. For example, CAN
.
*/
public final String country() {
return country;
}
/**
* Returns the value of the Geometry property for this object.
*
* @return The value of the Geometry property for this object.
*/
public final PlaceGeometry geometry() {
return geometry;
}
/**
*
* True
if the result is interpolated from other known places.
*
*
* False
if the Place is a known place.
*
*
* Not returned when the partner does not provide the information.
*
*
* For example, returns False
for an address location that is found in the partner data, but returns
* True
if an address does not exist in the partner data and its location is calculated by
* interpolating between other known addresses.
*
*
* @return True
if the result is interpolated from other known places.
*
* False
if the Place is a known place.
*
*
* Not returned when the partner does not provide the information.
*
*
* For example, returns False
for an address location that is found in the partner data, but
* returns True
if an address does not exist in the partner data and its location is calculated
* by interpolating between other known addresses.
*/
public final Boolean interpolated() {
return interpolated;
}
/**
*
* The full name and address of the point of interest such as a city, region, or country. For example,
* 123 Any Street, Any Town, USA
.
*
*
* @return The full name and address of the point of interest such as a city, region, or country. For example,
* 123 Any Street, Any Town, USA
.
*/
public final String label() {
return label;
}
/**
*
* A name for a local area, such as a city or town name. For example, Toronto
.
*
*
* @return A name for a local area, such as a city or town name. For example, Toronto
.
*/
public final String municipality() {
return municipality;
}
/**
*
* The name of a community district. For example, Downtown
.
*
*
* @return The name of a community district. For example, Downtown
.
*/
public final String neighborhood() {
return neighborhood;
}
/**
*
* A group of numbers and letters in a country-specific format, which accompanies the address for the purpose of
* identifying a location.
*
*
* @return A group of numbers and letters in a country-specific format, which accompanies the address for the
* purpose of identifying a location.
*/
public final String postalCode() {
return postalCode;
}
/**
*
* A name for an area or geographical division, such as a province or state name. For example,
* British Columbia
.
*
*
* @return A name for an area or geographical division, such as a province or state name. For example,
* British Columbia
.
*/
public final String region() {
return region;
}
/**
*
* The name for a street or a road to identify a location. For example, Main Street
.
*
*
* @return The name for a street or a road to identify a location. For example, Main Street
.
*/
public final String street() {
return street;
}
/**
*
* A county, or an area that's part of a larger region. For example, Metro Vancouver
.
*
*
* @return A county, or an area that's part of a larger region. For example, Metro Vancouver
.
*/
public final String subRegion() {
return subRegion;
}
/**
*
* The time zone in which the Place
is located. Returned only when using HERE as the selected partner.
*
*
* @return The time zone in which the Place
is located. Returned only when using HERE as the selected
* partner.
*/
public final TimeZone timeZone() {
return timeZone;
}
/**
*
* For addresses with multiple units, the unit identifier. Can include numbers and letters, for example
* 3B
or Unit 123
.
*
*
*
* Returned only for a place index that uses Esri as a data provider. Is not returned for
* SearchPlaceIndexForPosition
.
*
*
*
* @return For addresses with multiple units, the unit identifier. Can include numbers and letters, for example
* 3B
or Unit 123
.
*
* Returned only for a place index that uses Esri as a data provider. Is not returned for
* SearchPlaceIndexForPosition
.
*
*/
public final String unitNumber() {
return unitNumber;
}
/**
*
* For addresses with a UnitNumber
, the type of unit. For example, Apartment
.
*
*
* @return For addresses with a UnitNumber
, the type of unit. For example, Apartment
.
*/
public final String unitType() {
return unitType;
}
@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(addressNumber());
hashCode = 31 * hashCode + Objects.hashCode(country());
hashCode = 31 * hashCode + Objects.hashCode(geometry());
hashCode = 31 * hashCode + Objects.hashCode(interpolated());
hashCode = 31 * hashCode + Objects.hashCode(label());
hashCode = 31 * hashCode + Objects.hashCode(municipality());
hashCode = 31 * hashCode + Objects.hashCode(neighborhood());
hashCode = 31 * hashCode + Objects.hashCode(postalCode());
hashCode = 31 * hashCode + Objects.hashCode(region());
hashCode = 31 * hashCode + Objects.hashCode(street());
hashCode = 31 * hashCode + Objects.hashCode(subRegion());
hashCode = 31 * hashCode + Objects.hashCode(timeZone());
hashCode = 31 * hashCode + Objects.hashCode(unitNumber());
hashCode = 31 * hashCode + Objects.hashCode(unitType());
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 Place)) {
return false;
}
Place other = (Place) obj;
return Objects.equals(addressNumber(), other.addressNumber()) && Objects.equals(country(), other.country())
&& Objects.equals(geometry(), other.geometry()) && Objects.equals(interpolated(), other.interpolated())
&& Objects.equals(label(), other.label()) && Objects.equals(municipality(), other.municipality())
&& Objects.equals(neighborhood(), other.neighborhood()) && Objects.equals(postalCode(), other.postalCode())
&& Objects.equals(region(), other.region()) && Objects.equals(street(), other.street())
&& Objects.equals(subRegion(), other.subRegion()) && Objects.equals(timeZone(), other.timeZone())
&& Objects.equals(unitNumber(), other.unitNumber()) && Objects.equals(unitType(), other.unitType());
}
/**
* 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("Place").add("AddressNumber", addressNumber()).add("Country", country())
.add("Geometry", geometry()).add("Interpolated", interpolated()).add("Label", label())
.add("Municipality", municipality()).add("Neighborhood", neighborhood()).add("PostalCode", postalCode())
.add("Region", region()).add("Street", street()).add("SubRegion", subRegion()).add("TimeZone", timeZone())
.add("UnitNumber", unitNumber()).add("UnitType", unitType()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "AddressNumber":
return Optional.ofNullable(clazz.cast(addressNumber()));
case "Country":
return Optional.ofNullable(clazz.cast(country()));
case "Geometry":
return Optional.ofNullable(clazz.cast(geometry()));
case "Interpolated":
return Optional.ofNullable(clazz.cast(interpolated()));
case "Label":
return Optional.ofNullable(clazz.cast(label()));
case "Municipality":
return Optional.ofNullable(clazz.cast(municipality()));
case "Neighborhood":
return Optional.ofNullable(clazz.cast(neighborhood()));
case "PostalCode":
return Optional.ofNullable(clazz.cast(postalCode()));
case "Region":
return Optional.ofNullable(clazz.cast(region()));
case "Street":
return Optional.ofNullable(clazz.cast(street()));
case "SubRegion":
return Optional.ofNullable(clazz.cast(subRegion()));
case "TimeZone":
return Optional.ofNullable(clazz.cast(timeZone()));
case "UnitNumber":
return Optional.ofNullable(clazz.cast(unitNumber()));
case "UnitType":
return Optional.ofNullable(clazz.cast(unitType()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function