software.amazon.awssdk.services.iotfleetwise.model.Attribute Maven / Gradle / Ivy
Show all versions of iotfleetwise 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.iotfleetwise.model;
import java.io.Serializable;
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 signal that represents static information about the vehicle, such as engine type or manufacturing date.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Attribute implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField FULLY_QUALIFIED_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("fullyQualifiedName").getter(getter(Attribute::fullyQualifiedName))
.setter(setter(Builder::fullyQualifiedName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("fullyQualifiedName").build())
.build();
private static final SdkField DATA_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("dataType").getter(getter(Attribute::dataTypeAsString)).setter(setter(Builder::dataType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("dataType").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("description").getter(getter(Attribute::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("description").build()).build();
private static final SdkField UNIT_FIELD = SdkField. builder(MarshallingType.STRING).memberName("unit")
.getter(getter(Attribute::unit)).setter(setter(Builder::unit))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("unit").build()).build();
private static final SdkField> ALLOWED_VALUES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("allowedValues")
.getter(getter(Attribute::allowedValues))
.setter(setter(Builder::allowedValues))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("allowedValues").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 SdkField MIN_FIELD = SdkField. builder(MarshallingType.DOUBLE).memberName("min")
.getter(getter(Attribute::min)).setter(setter(Builder::min))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("min").build()).build();
private static final SdkField MAX_FIELD = SdkField. builder(MarshallingType.DOUBLE).memberName("max")
.getter(getter(Attribute::max)).setter(setter(Builder::max))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("max").build()).build();
private static final SdkField ASSIGNED_VALUE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("assignedValue").getter(getter(Attribute::assignedValue)).setter(setter(Builder::assignedValue))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("assignedValue").build()).build();
private static final SdkField DEFAULT_VALUE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("defaultValue").getter(getter(Attribute::defaultValue)).setter(setter(Builder::defaultValue))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("defaultValue").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(FULLY_QUALIFIED_NAME_FIELD,
DATA_TYPE_FIELD, DESCRIPTION_FIELD, UNIT_FIELD, ALLOWED_VALUES_FIELD, MIN_FIELD, MAX_FIELD, ASSIGNED_VALUE_FIELD,
DEFAULT_VALUE_FIELD));
private static final long serialVersionUID = 1L;
private final String fullyQualifiedName;
private final String dataType;
private final String description;
private final String unit;
private final List allowedValues;
private final Double min;
private final Double max;
private final String assignedValue;
private final String defaultValue;
private Attribute(BuilderImpl builder) {
this.fullyQualifiedName = builder.fullyQualifiedName;
this.dataType = builder.dataType;
this.description = builder.description;
this.unit = builder.unit;
this.allowedValues = builder.allowedValues;
this.min = builder.min;
this.max = builder.max;
this.assignedValue = builder.assignedValue;
this.defaultValue = builder.defaultValue;
}
/**
*
* The fully qualified name of the attribute. For example, the fully qualified name of an attribute might be
* Vehicle.Body.Engine.Type
.
*
*
* @return The fully qualified name of the attribute. For example, the fully qualified name of an attribute might be
* Vehicle.Body.Engine.Type
.
*/
public final String fullyQualifiedName() {
return fullyQualifiedName;
}
/**
*
* The specified data type of the attribute.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #dataType} will
* return {@link NodeDataType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #dataTypeAsString}.
*
*
* @return The specified data type of the attribute.
* @see NodeDataType
*/
public final NodeDataType dataType() {
return NodeDataType.fromValue(dataType);
}
/**
*
* The specified data type of the attribute.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #dataType} will
* return {@link NodeDataType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #dataTypeAsString}.
*
*
* @return The specified data type of the attribute.
* @see NodeDataType
*/
public final String dataTypeAsString() {
return dataType;
}
/**
*
* A brief description of the attribute.
*
*
* @return A brief description of the attribute.
*/
public final String description() {
return description;
}
/**
*
* The scientific unit for the attribute.
*
*
* @return The scientific unit for the attribute.
*/
public final String unit() {
return unit;
}
/**
* For responses, this returns true if the service returned a value for the AllowedValues 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 hasAllowedValues() {
return allowedValues != null && !(allowedValues instanceof SdkAutoConstructList);
}
/**
*
* A list of possible values an attribute can be assigned.
*
*
* 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 #hasAllowedValues} method.
*
*
* @return A list of possible values an attribute can be assigned.
*/
public final List allowedValues() {
return allowedValues;
}
/**
*
* The specified possible minimum value of the attribute.
*
*
* @return The specified possible minimum value of the attribute.
*/
public final Double min() {
return min;
}
/**
*
* The specified possible maximum value of the attribute.
*
*
* @return The specified possible maximum value of the attribute.
*/
public final Double max() {
return max;
}
/**
*
* A specified value for the attribute.
*
*
* @return A specified value for the attribute.
*/
public final String assignedValue() {
return assignedValue;
}
/**
*
* The default value of the attribute.
*
*
* @return The default value of the attribute.
*/
public final String defaultValue() {
return defaultValue;
}
@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(fullyQualifiedName());
hashCode = 31 * hashCode + Objects.hashCode(dataTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(unit());
hashCode = 31 * hashCode + Objects.hashCode(hasAllowedValues() ? allowedValues() : null);
hashCode = 31 * hashCode + Objects.hashCode(min());
hashCode = 31 * hashCode + Objects.hashCode(max());
hashCode = 31 * hashCode + Objects.hashCode(assignedValue());
hashCode = 31 * hashCode + Objects.hashCode(defaultValue());
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 Attribute)) {
return false;
}
Attribute other = (Attribute) obj;
return Objects.equals(fullyQualifiedName(), other.fullyQualifiedName())
&& Objects.equals(dataTypeAsString(), other.dataTypeAsString())
&& Objects.equals(description(), other.description()) && Objects.equals(unit(), other.unit())
&& hasAllowedValues() == other.hasAllowedValues() && Objects.equals(allowedValues(), other.allowedValues())
&& Objects.equals(min(), other.min()) && Objects.equals(max(), other.max())
&& Objects.equals(assignedValue(), other.assignedValue()) && Objects.equals(defaultValue(), other.defaultValue());
}
/**
* 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("Attribute").add("FullyQualifiedName", fullyQualifiedName()).add("DataType", dataTypeAsString())
.add("Description", description()).add("Unit", unit())
.add("AllowedValues", hasAllowedValues() ? allowedValues() : null).add("Min", min()).add("Max", max())
.add("AssignedValue", assignedValue()).add("DefaultValue", defaultValue()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "fullyQualifiedName":
return Optional.ofNullable(clazz.cast(fullyQualifiedName()));
case "dataType":
return Optional.ofNullable(clazz.cast(dataTypeAsString()));
case "description":
return Optional.ofNullable(clazz.cast(description()));
case "unit":
return Optional.ofNullable(clazz.cast(unit()));
case "allowedValues":
return Optional.ofNullable(clazz.cast(allowedValues()));
case "min":
return Optional.ofNullable(clazz.cast(min()));
case "max":
return Optional.ofNullable(clazz.cast(max()));
case "assignedValue":
return Optional.ofNullable(clazz.cast(assignedValue()));
case "defaultValue":
return Optional.ofNullable(clazz.cast(defaultValue()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function