software.amazon.awssdk.services.iotfleetwise.model.Node 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.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
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.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;
/**
*
* A general abstraction of a signal. A node can be specified as an actuator, attribute, branch, or sensor.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Node implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField BRANCH_FIELD = SdkField. builder(MarshallingType.SDK_POJO).memberName("branch")
.getter(getter(Node::branch)).setter(setter(Builder::branch)).constructor(Branch::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("branch").build()).build();
private static final SdkField SENSOR_FIELD = SdkField. builder(MarshallingType.SDK_POJO).memberName("sensor")
.getter(getter(Node::sensor)).setter(setter(Builder::sensor)).constructor(Sensor::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("sensor").build()).build();
private static final SdkField ACTUATOR_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("actuator").getter(getter(Node::actuator)).setter(setter(Builder::actuator))
.constructor(Actuator::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("actuator").build()).build();
private static final SdkField ATTRIBUTE_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("attribute").getter(getter(Node::attribute)).setter(setter(Builder::attribute))
.constructor(Attribute::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("attribute").build()).build();
private static final SdkField STRUCT_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("struct").getter(getter(Node::struct)).setter(setter(Builder::struct)).constructor(CustomStruct::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("struct").build()).build();
private static final SdkField PROPERTY_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("property").getter(getter(Node::property)).setter(setter(Builder::property))
.constructor(CustomProperty::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("property").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BRANCH_FIELD, SENSOR_FIELD,
ACTUATOR_FIELD, ATTRIBUTE_FIELD, STRUCT_FIELD, PROPERTY_FIELD));
private static final long serialVersionUID = 1L;
private final Branch branch;
private final Sensor sensor;
private final Actuator actuator;
private final Attribute attribute;
private final CustomStruct struct;
private final CustomProperty property;
private final Type type;
private Node(BuilderImpl builder) {
this.branch = builder.branch;
this.sensor = builder.sensor;
this.actuator = builder.actuator;
this.attribute = builder.attribute;
this.struct = builder.struct;
this.property = builder.property;
this.type = builder.type;
}
/**
*
* Information about a node specified as a branch.
*
*
*
* A group of signals that are defined in a hierarchical structure.
*
*
*
* @return Information about a node specified as a branch.
*
* A group of signals that are defined in a hierarchical structure.
*
*/
public final Branch branch() {
return branch;
}
/**
* Returns the value of the Sensor property for this object.
*
* @return The value of the Sensor property for this object.
*/
public final Sensor sensor() {
return sensor;
}
/**
*
* Information about a node specified as an actuator.
*
*
*
* An actuator is a digital representation of a vehicle device.
*
*
*
* @return Information about a node specified as an actuator.
*
* An actuator is a digital representation of a vehicle device.
*
*/
public final Actuator actuator() {
return actuator;
}
/**
*
* Information about a node specified as an attribute.
*
*
*
* An attribute represents static information about a vehicle.
*
*
*
* @return Information about a node specified as an attribute.
*
* An attribute represents static information about a vehicle.
*
*/
public final Attribute attribute() {
return attribute;
}
/**
*
* Represents a complex or higher-order data structure.
*
*
* @return Represents a complex or higher-order data structure.
*/
public final CustomStruct struct() {
return struct;
}
/**
*
* Represents a member of the complex data structure. The datatype
of the property can be either
* primitive or another struct
.
*
*
* @return Represents a member of the complex data structure. The datatype
of the property can be
* either primitive or another struct
.
*/
public final CustomProperty property() {
return property;
}
@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(branch());
hashCode = 31 * hashCode + Objects.hashCode(sensor());
hashCode = 31 * hashCode + Objects.hashCode(actuator());
hashCode = 31 * hashCode + Objects.hashCode(attribute());
hashCode = 31 * hashCode + Objects.hashCode(struct());
hashCode = 31 * hashCode + Objects.hashCode(property());
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 Node)) {
return false;
}
Node other = (Node) obj;
return Objects.equals(branch(), other.branch()) && Objects.equals(sensor(), other.sensor())
&& Objects.equals(actuator(), other.actuator()) && Objects.equals(attribute(), other.attribute())
&& Objects.equals(struct(), other.struct()) && Objects.equals(property(), other.property());
}
/**
* 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("Node").add("Branch", branch()).add("Sensor", sensor()).add("Actuator", actuator())
.add("Attribute", attribute()).add("Struct", struct()).add("Property", property()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "branch":
return Optional.ofNullable(clazz.cast(branch()));
case "sensor":
return Optional.ofNullable(clazz.cast(sensor()));
case "actuator":
return Optional.ofNullable(clazz.cast(actuator()));
case "attribute":
return Optional.ofNullable(clazz.cast(attribute()));
case "struct":
return Optional.ofNullable(clazz.cast(struct()));
case "property":
return Optional.ofNullable(clazz.cast(property()));
default:
return Optional.empty();
}
}
/**
* Create an instance of this class with {@link #branch()} initialized to the given value.
*
*
* Information about a node specified as a branch.
*
*
*
* A group of signals that are defined in a hierarchical structure.
*
*
*
* @param branch
* Information about a node specified as a branch.
*
* A group of signals that are defined in a hierarchical structure.
*
*/
public static Node fromBranch(Branch branch) {
return builder().branch(branch).build();
}
/**
* Create an instance of this class with {@link #branch()} initialized to the given value.
*
*
* Information about a node specified as a branch.
*
*
*
* A group of signals that are defined in a hierarchical structure.
*
*
*
* @param branch
* Information about a node specified as a branch.
*
* A group of signals that are defined in a hierarchical structure.
*
*/
public static Node fromBranch(Consumer branch) {
Branch.Builder builder = Branch.builder();
branch.accept(builder);
return fromBranch(builder.build());
}
/**
* Create an instance of this class with {@link #sensor()} initialized to the given value.
*
* Sets the value of the Sensor property for this object.
*
* @param sensor
* The new value for the Sensor property for this object.
*/
public static Node fromSensor(Sensor sensor) {
return builder().sensor(sensor).build();
}
/**
* Create an instance of this class with {@link #sensor()} initialized to the given value.
*
* Sets the value of the Sensor property for this object.
*
* @param sensor
* The new value for the Sensor property for this object.
*/
public static Node fromSensor(Consumer sensor) {
Sensor.Builder builder = Sensor.builder();
sensor.accept(builder);
return fromSensor(builder.build());
}
/**
* Create an instance of this class with {@link #actuator()} initialized to the given value.
*
*
* Information about a node specified as an actuator.
*
*
*
* An actuator is a digital representation of a vehicle device.
*
*
*
* @param actuator
* Information about a node specified as an actuator.
*
* An actuator is a digital representation of a vehicle device.
*
*/
public static Node fromActuator(Actuator actuator) {
return builder().actuator(actuator).build();
}
/**
* Create an instance of this class with {@link #actuator()} initialized to the given value.
*
*
* Information about a node specified as an actuator.
*
*
*
* An actuator is a digital representation of a vehicle device.
*
*
*
* @param actuator
* Information about a node specified as an actuator.
*
* An actuator is a digital representation of a vehicle device.
*
*/
public static Node fromActuator(Consumer actuator) {
Actuator.Builder builder = Actuator.builder();
actuator.accept(builder);
return fromActuator(builder.build());
}
/**
* Create an instance of this class with {@link #attribute()} initialized to the given value.
*
*
* Information about a node specified as an attribute.
*
*
*
* An attribute represents static information about a vehicle.
*
*
*
* @param attribute
* Information about a node specified as an attribute.
*
* An attribute represents static information about a vehicle.
*
*/
public static Node fromAttribute(Attribute attribute) {
return builder().attribute(attribute).build();
}
/**
* Create an instance of this class with {@link #attribute()} initialized to the given value.
*
*
* Information about a node specified as an attribute.
*
*
*
* An attribute represents static information about a vehicle.
*
*
*
* @param attribute
* Information about a node specified as an attribute.
*
* An attribute represents static information about a vehicle.
*
*/
public static Node fromAttribute(Consumer attribute) {
Attribute.Builder builder = Attribute.builder();
attribute.accept(builder);
return fromAttribute(builder.build());
}
/**
* Create an instance of this class with {@link #struct()} initialized to the given value.
*
*
* Represents a complex or higher-order data structure.
*
*
* @param struct
* Represents a complex or higher-order data structure.
*/
public static Node fromStruct(CustomStruct struct) {
return builder().struct(struct).build();
}
/**
* Create an instance of this class with {@link #struct()} initialized to the given value.
*
*
* Represents a complex or higher-order data structure.
*
*
* @param struct
* Represents a complex or higher-order data structure.
*/
public static Node fromStruct(Consumer struct) {
CustomStruct.Builder builder = CustomStruct.builder();
struct.accept(builder);
return fromStruct(builder.build());
}
/**
* Create an instance of this class with {@link #property()} initialized to the given value.
*
*
* Represents a member of the complex data structure. The datatype
of the property can be either
* primitive or another struct
.
*
*
* @param property
* Represents a member of the complex data structure. The datatype
of the property can be either
* primitive or another struct
.
*/
public static Node fromProperty(CustomProperty property) {
return builder().property(property).build();
}
/**
* Create an instance of this class with {@link #property()} initialized to the given value.
*
*
* Represents a member of the complex data structure. The datatype
of the property can be either
* primitive or another struct
.
*
*
* @param property
* Represents a member of the complex data structure. The datatype
of the property can be either
* primitive or another struct
.
*/
public static Node fromProperty(Consumer property) {
CustomProperty.Builder builder = CustomProperty.builder();
property.accept(builder);
return fromProperty(builder.build());
}
/**
* Retrieve an enum value representing which member of this object is populated.
*
* When this class is returned in a service response, this will be {@link Type#UNKNOWN_TO_SDK_VERSION} if the
* service returned a member that is only known to a newer SDK version.
*
* When this class is created directly in your code, this will be {@link Type#UNKNOWN_TO_SDK_VERSION} if zero
* members are set, and {@code null} if more than one member is set.
*/
public Type type() {
return type;
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function