software.amazon.awssdk.services.iottwinmaker.model.PropertyValue Maven / Gradle / Ivy
Show all versions of iottwinmaker 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.iottwinmaker.model;
import java.io.Serializable;
import java.time.Instant;
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;
/**
*
* An object that contains information about a value for a time series property.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class PropertyValue implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField TIME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("time")
.getter(getter(PropertyValue::time)).setter(setter(Builder::time))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("time").build()).build();
private static final SdkField TIMESTAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("timestamp").getter(getter(PropertyValue::timestamp)).setter(setter(Builder::timestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("timestamp").build()).build();
private static final SdkField VALUE_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("value").getter(getter(PropertyValue::value)).setter(setter(Builder::value))
.constructor(DataValue::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("value").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TIME_FIELD, TIMESTAMP_FIELD,
VALUE_FIELD));
private static final long serialVersionUID = 1L;
private final String time;
private final Instant timestamp;
private final DataValue value;
private PropertyValue(BuilderImpl builder) {
this.time = builder.time;
this.timestamp = builder.timestamp;
this.value = builder.value;
}
/**
*
* ISO8601 DateTime of a value for a time series property.
*
*
* The time for when the property value was recorded in ISO 8601 format:
* YYYY-MM-DDThh:mm:ss[.SSSSSSSSS][Z/±HH:mm].
*
*
* -
*
* [YYYY]: year
*
*
* -
*
* [MM]: month
*
*
* -
*
* [DD]: day
*
*
* -
*
* [hh]: hour
*
*
* -
*
* [mm]: minute
*
*
* -
*
* [ss]: seconds
*
*
* -
*
* [.SSSSSSSSS]: additional precision, where precedence is maintained. For example: [.573123] is equal to
* 573123000 nanoseconds.
*
*
* -
*
* Z: default timezone UTC
*
*
* -
*
* ± HH:mm: time zone offset in Hours and Minutes.
*
*
*
*
* Required sub-fields: YYYY-MM-DDThh:mm:ss and [Z/±HH:mm]
*
*
* @return ISO8601 DateTime of a value for a time series property.
*
* The time for when the property value was recorded in ISO 8601 format:
* YYYY-MM-DDThh:mm:ss[.SSSSSSSSS][Z/±HH:mm].
*
*
* -
*
* [YYYY]: year
*
*
* -
*
* [MM]: month
*
*
* -
*
* [DD]: day
*
*
* -
*
* [hh]: hour
*
*
* -
*
* [mm]: minute
*
*
* -
*
* [ss]: seconds
*
*
* -
*
* [.SSSSSSSSS]: additional precision, where precedence is maintained. For example: [.573123] is
* equal to 573123000 nanoseconds.
*
*
* -
*
* Z: default timezone UTC
*
*
* -
*
* ± HH:mm: time zone offset in Hours and Minutes.
*
*
*
*
* Required sub-fields: YYYY-MM-DDThh:mm:ss and [Z/±HH:mm]
*/
public final String time() {
return time;
}
/**
*
* The timestamp of a value for a time series property.
*
*
* @return The timestamp of a value for a time series property.
* @deprecated This field is deprecated and will throw an error in the future. Use time instead.
*/
@Deprecated
public final Instant timestamp() {
return timestamp;
}
/**
*
* An object that specifies a value for a time series property.
*
*
* @return An object that specifies a value for a time series property.
*/
public final DataValue value() {
return value;
}
@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(time());
hashCode = 31 * hashCode + Objects.hashCode(timestamp());
hashCode = 31 * hashCode + Objects.hashCode(value());
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 PropertyValue)) {
return false;
}
PropertyValue other = (PropertyValue) obj;
return Objects.equals(time(), other.time()) && Objects.equals(timestamp(), other.timestamp())
&& Objects.equals(value(), other.value());
}
/**
* 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("PropertyValue").add("Time", time()).add("Timestamp", timestamp()).add("Value", value()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "time":
return Optional.ofNullable(clazz.cast(time()));
case "timestamp":
return Optional.ofNullable(clazz.cast(timestamp()));
case "value":
return Optional.ofNullable(clazz.cast(value()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function