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

software.amazon.awssdk.services.location.model.GetDevicePositionResponse 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.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.traits.MapTrait;
import software.amazon.awssdk.core.traits.TimestampFormatTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class GetDevicePositionResponse extends LocationResponse implements
        ToCopyableBuilder {
    private static final SdkField ACCURACY_FIELD = SdkField
            . builder(MarshallingType.SDK_POJO).memberName("Accuracy")
            .getter(getter(GetDevicePositionResponse::accuracy)).setter(setter(Builder::accuracy))
            .constructor(PositionalAccuracy::builder)
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Accuracy").build()).build();

    private static final SdkField DEVICE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("DeviceId").getter(getter(GetDevicePositionResponse::deviceId)).setter(setter(Builder::deviceId))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DeviceId").build()).build();

    private static final SdkField> POSITION_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("Position")
            .getter(getter(GetDevicePositionResponse::position))
            .setter(setter(Builder::position))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Position").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.DOUBLE)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField> POSITION_PROPERTIES_FIELD = SdkField
            .> builder(MarshallingType.MAP)
            .memberName("PositionProperties")
            .getter(getter(GetDevicePositionResponse::positionProperties))
            .setter(setter(Builder::positionProperties))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PositionProperties").build(),
                    MapTrait.builder()
                            .keyLocationName("key")
                            .valueLocationName("value")
                            .valueFieldInfo(
                                    SdkField. builder(MarshallingType.STRING)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("value").build()).build()).build()).build();

    private static final SdkField RECEIVED_TIME_FIELD = SdkField
            . builder(MarshallingType.INSTANT)
            .memberName("ReceivedTime")
            .getter(getter(GetDevicePositionResponse::receivedTime))
            .setter(setter(Builder::receivedTime))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReceivedTime").build(),
                    TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();

    private static final SdkField SAMPLE_TIME_FIELD = SdkField
            . builder(MarshallingType.INSTANT)
            .memberName("SampleTime")
            .getter(getter(GetDevicePositionResponse::sampleTime))
            .setter(setter(Builder::sampleTime))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SampleTime").build(),
                    TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ACCURACY_FIELD,
            DEVICE_ID_FIELD, POSITION_FIELD, POSITION_PROPERTIES_FIELD, RECEIVED_TIME_FIELD, SAMPLE_TIME_FIELD));

    private final PositionalAccuracy accuracy;

    private final String deviceId;

    private final List position;

    private final Map positionProperties;

    private final Instant receivedTime;

    private final Instant sampleTime;

    private GetDevicePositionResponse(BuilderImpl builder) {
        super(builder);
        this.accuracy = builder.accuracy;
        this.deviceId = builder.deviceId;
        this.position = builder.position;
        this.positionProperties = builder.positionProperties;
        this.receivedTime = builder.receivedTime;
        this.sampleTime = builder.sampleTime;
    }

    /**
     * 

* The accuracy of the device position. *

* * @return The accuracy of the device position. */ public final PositionalAccuracy accuracy() { return accuracy; } /** *

* The device whose position you retrieved. *

* * @return The device whose position you retrieved. */ public final String deviceId() { return deviceId; } /** * For responses, this returns true if the service returned a value for the Position 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 hasPosition() { return position != null && !(position instanceof SdkAutoConstructList); } /** *

* The last known device position. *

*

* 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 #hasPosition} method. *

* * @return The last known device position. */ public final List position() { return position; } /** * For responses, this returns true if the service returned a value for the PositionProperties 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 hasPositionProperties() { return positionProperties != null && !(positionProperties instanceof SdkAutoConstructMap); } /** *

* The properties associated with the position. *

*

* 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 #hasPositionProperties} method. *

* * @return The properties associated with the position. */ public final Map positionProperties() { return positionProperties; } /** *

* The timestamp for when the tracker resource received the device position in ISO 8601 format: * YYYY-MM-DDThh:mm:ss.sssZ. *

* * @return The timestamp for when the tracker resource received the device position in ISO 8601 format: * YYYY-MM-DDThh:mm:ss.sssZ. */ public final Instant receivedTime() { return receivedTime; } /** *

* The timestamp at which the device's position was determined. Uses ISO 8601 format: * YYYY-MM-DDThh:mm:ss.sssZ. *

* * @return The timestamp at which the device's position was determined. Uses ISO 8601 format: * YYYY-MM-DDThh:mm:ss.sssZ. */ public final Instant sampleTime() { return sampleTime; } @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 + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(accuracy()); hashCode = 31 * hashCode + Objects.hashCode(deviceId()); hashCode = 31 * hashCode + Objects.hashCode(hasPosition() ? position() : null); hashCode = 31 * hashCode + Objects.hashCode(hasPositionProperties() ? positionProperties() : null); hashCode = 31 * hashCode + Objects.hashCode(receivedTime()); hashCode = 31 * hashCode + Objects.hashCode(sampleTime()); return hashCode; } @Override public final boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof GetDevicePositionResponse)) { return false; } GetDevicePositionResponse other = (GetDevicePositionResponse) obj; return Objects.equals(accuracy(), other.accuracy()) && Objects.equals(deviceId(), other.deviceId()) && hasPosition() == other.hasPosition() && Objects.equals(position(), other.position()) && hasPositionProperties() == other.hasPositionProperties() && Objects.equals(positionProperties(), other.positionProperties()) && Objects.equals(receivedTime(), other.receivedTime()) && Objects.equals(sampleTime(), other.sampleTime()); } /** * 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("GetDevicePositionResponse").add("Accuracy", accuracy()).add("DeviceId", deviceId()) .add("Position", position() == null ? null : "*** Sensitive Data Redacted ***") .add("PositionProperties", positionProperties() == null ? null : "*** Sensitive Data Redacted ***") .add("ReceivedTime", receivedTime()).add("SampleTime", sampleTime()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Accuracy": return Optional.ofNullable(clazz.cast(accuracy())); case "DeviceId": return Optional.ofNullable(clazz.cast(deviceId())); case "Position": return Optional.ofNullable(clazz.cast(position())); case "PositionProperties": return Optional.ofNullable(clazz.cast(positionProperties())); case "ReceivedTime": return Optional.ofNullable(clazz.cast(receivedTime())); case "SampleTime": return Optional.ofNullable(clazz.cast(sampleTime())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((GetDevicePositionResponse) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends LocationResponse.Builder, SdkPojo, CopyableBuilder { /** *

* The accuracy of the device position. *

* * @param accuracy * The accuracy of the device position. * @return Returns a reference to this object so that method calls can be chained together. */ Builder accuracy(PositionalAccuracy accuracy); /** *

* The accuracy of the device position. *

* This is a convenience method that creates an instance of the {@link PositionalAccuracy.Builder} avoiding the * need to create one manually via {@link PositionalAccuracy#builder()}. * *

* When the {@link Consumer} completes, {@link PositionalAccuracy.Builder#build()} is called immediately and its * result is passed to {@link #accuracy(PositionalAccuracy)}. * * @param accuracy * a consumer that will call methods on {@link PositionalAccuracy.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #accuracy(PositionalAccuracy) */ default Builder accuracy(Consumer accuracy) { return accuracy(PositionalAccuracy.builder().applyMutation(accuracy).build()); } /** *

* The device whose position you retrieved. *

* * @param deviceId * The device whose position you retrieved. * @return Returns a reference to this object so that method calls can be chained together. */ Builder deviceId(String deviceId); /** *

* The last known device position. *

* * @param position * The last known device position. * @return Returns a reference to this object so that method calls can be chained together. */ Builder position(Collection position); /** *

* The last known device position. *

* * @param position * The last known device position. * @return Returns a reference to this object so that method calls can be chained together. */ Builder position(Double... position); /** *

* The properties associated with the position. *

* * @param positionProperties * The properties associated with the position. * @return Returns a reference to this object so that method calls can be chained together. */ Builder positionProperties(Map positionProperties); /** *

* The timestamp for when the tracker resource received the device position in ISO 8601 format: * YYYY-MM-DDThh:mm:ss.sssZ. *

* * @param receivedTime * The timestamp for when the tracker resource received the device position in ISO 8601 format: * YYYY-MM-DDThh:mm:ss.sssZ. * @return Returns a reference to this object so that method calls can be chained together. */ Builder receivedTime(Instant receivedTime); /** *

* The timestamp at which the device's position was determined. Uses ISO 8601 format: * YYYY-MM-DDThh:mm:ss.sssZ. *

* * @param sampleTime * The timestamp at which the device's position was determined. Uses ISO 8601 format: * YYYY-MM-DDThh:mm:ss.sssZ. * @return Returns a reference to this object so that method calls can be chained together. */ Builder sampleTime(Instant sampleTime); } static final class BuilderImpl extends LocationResponse.BuilderImpl implements Builder { private PositionalAccuracy accuracy; private String deviceId; private List position = DefaultSdkAutoConstructList.getInstance(); private Map positionProperties = DefaultSdkAutoConstructMap.getInstance(); private Instant receivedTime; private Instant sampleTime; private BuilderImpl() { } private BuilderImpl(GetDevicePositionResponse model) { super(model); accuracy(model.accuracy); deviceId(model.deviceId); position(model.position); positionProperties(model.positionProperties); receivedTime(model.receivedTime); sampleTime(model.sampleTime); } public final PositionalAccuracy.Builder getAccuracy() { return accuracy != null ? accuracy.toBuilder() : null; } public final void setAccuracy(PositionalAccuracy.BuilderImpl accuracy) { this.accuracy = accuracy != null ? accuracy.build() : null; } @Override public final Builder accuracy(PositionalAccuracy accuracy) { this.accuracy = accuracy; return this; } public final String getDeviceId() { return deviceId; } public final void setDeviceId(String deviceId) { this.deviceId = deviceId; } @Override public final Builder deviceId(String deviceId) { this.deviceId = deviceId; return this; } public final Collection getPosition() { if (position instanceof SdkAutoConstructList) { return null; } return position; } public final void setPosition(Collection position) { this.position = PositionCopier.copy(position); } @Override public final Builder position(Collection position) { this.position = PositionCopier.copy(position); return this; } @Override @SafeVarargs public final Builder position(Double... position) { position(Arrays.asList(position)); return this; } public final Map getPositionProperties() { if (positionProperties instanceof SdkAutoConstructMap) { return null; } return positionProperties; } public final void setPositionProperties(Map positionProperties) { this.positionProperties = PropertyMapCopier.copy(positionProperties); } @Override public final Builder positionProperties(Map positionProperties) { this.positionProperties = PropertyMapCopier.copy(positionProperties); return this; } public final Instant getReceivedTime() { return receivedTime; } public final void setReceivedTime(Instant receivedTime) { this.receivedTime = receivedTime; } @Override public final Builder receivedTime(Instant receivedTime) { this.receivedTime = receivedTime; return this; } public final Instant getSampleTime() { return sampleTime; } public final void setSampleTime(Instant sampleTime) { this.sampleTime = sampleTime; } @Override public final Builder sampleTime(Instant sampleTime) { this.sampleTime = sampleTime; return this; } @Override public GetDevicePositionResponse build() { return new GetDevicePositionResponse(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy