software.amazon.awssdk.services.iotfleetwise.model.CanSignal 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.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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Information about a single controller area network (CAN) signal and the messages it receives and transmits.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CanSignal implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField MESSAGE_ID_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("messageId").getter(getter(CanSignal::messageId)).setter(setter(Builder::messageId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("messageId").build()).build();
private static final SdkField IS_BIG_ENDIAN_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("isBigEndian").getter(getter(CanSignal::isBigEndian)).setter(setter(Builder::isBigEndian))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("isBigEndian").build()).build();
private static final SdkField IS_SIGNED_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("isSigned").getter(getter(CanSignal::isSigned)).setter(setter(Builder::isSigned))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("isSigned").build()).build();
private static final SdkField START_BIT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("startBit").getter(getter(CanSignal::startBit)).setter(setter(Builder::startBit))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("startBit").build()).build();
private static final SdkField OFFSET_FIELD = SdkField. builder(MarshallingType.DOUBLE).memberName("offset")
.getter(getter(CanSignal::offset)).setter(setter(Builder::offset))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("offset").build()).build();
private static final SdkField FACTOR_FIELD = SdkField. builder(MarshallingType.DOUBLE).memberName("factor")
.getter(getter(CanSignal::factor)).setter(setter(Builder::factor))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("factor").build()).build();
private static final SdkField LENGTH_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("length").getter(getter(CanSignal::length)).setter(setter(Builder::length))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("length").build()).build();
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("name")
.getter(getter(CanSignal::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("name").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(MESSAGE_ID_FIELD,
IS_BIG_ENDIAN_FIELD, IS_SIGNED_FIELD, START_BIT_FIELD, OFFSET_FIELD, FACTOR_FIELD, LENGTH_FIELD, NAME_FIELD));
private static final long serialVersionUID = 1L;
private final Integer messageId;
private final Boolean isBigEndian;
private final Boolean isSigned;
private final Integer startBit;
private final Double offset;
private final Double factor;
private final Integer length;
private final String name;
private CanSignal(BuilderImpl builder) {
this.messageId = builder.messageId;
this.isBigEndian = builder.isBigEndian;
this.isSigned = builder.isSigned;
this.startBit = builder.startBit;
this.offset = builder.offset;
this.factor = builder.factor;
this.length = builder.length;
this.name = builder.name;
}
/**
*
* The ID of the message.
*
*
* @return The ID of the message.
*/
public final Integer messageId() {
return messageId;
}
/**
*
* Whether the byte ordering of a CAN message is big-endian.
*
*
* @return Whether the byte ordering of a CAN message is big-endian.
*/
public final Boolean isBigEndian() {
return isBigEndian;
}
/**
*
* Whether the message data is specified as a signed value.
*
*
* @return Whether the message data is specified as a signed value.
*/
public final Boolean isSigned() {
return isSigned;
}
/**
*
* Indicates the beginning of the CAN signal. This should always be the least significant bit (LSB).
*
*
* This value might be different from the value in a DBC file. For little endian signals, startBit
is
* the same value as in the DBC file. For big endian signals in a DBC file, the start bit is the most significant
* bit (MSB). You will have to calculate the LSB instead and pass it as the startBit
.
*
*
* @return Indicates the beginning of the CAN signal. This should always be the least significant bit (LSB).
*
* This value might be different from the value in a DBC file. For little endian signals,
* startBit
is the same value as in the DBC file. For big endian signals in a DBC file, the
* start bit is the most significant bit (MSB). You will have to calculate the LSB instead and pass it as
* the startBit
.
*/
public final Integer startBit() {
return startBit;
}
/**
*
* The offset used to calculate the signal value. Combined with factor, the calculation is
* value = raw_value * factor + offset
.
*
*
* @return The offset used to calculate the signal value. Combined with factor, the calculation is
* value = raw_value * factor + offset
.
*/
public final Double offset() {
return offset;
}
/**
*
* A multiplier used to decode the CAN message.
*
*
* @return A multiplier used to decode the CAN message.
*/
public final Double factor() {
return factor;
}
/**
*
* How many bytes of data are in the message.
*
*
* @return How many bytes of data are in the message.
*/
public final Integer length() {
return length;
}
/**
*
* The name of the signal.
*
*
* @return The name of the signal.
*/
public final String name() {
return name;
}
@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(messageId());
hashCode = 31 * hashCode + Objects.hashCode(isBigEndian());
hashCode = 31 * hashCode + Objects.hashCode(isSigned());
hashCode = 31 * hashCode + Objects.hashCode(startBit());
hashCode = 31 * hashCode + Objects.hashCode(offset());
hashCode = 31 * hashCode + Objects.hashCode(factor());
hashCode = 31 * hashCode + Objects.hashCode(length());
hashCode = 31 * hashCode + Objects.hashCode(name());
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 CanSignal)) {
return false;
}
CanSignal other = (CanSignal) obj;
return Objects.equals(messageId(), other.messageId()) && Objects.equals(isBigEndian(), other.isBigEndian())
&& Objects.equals(isSigned(), other.isSigned()) && Objects.equals(startBit(), other.startBit())
&& Objects.equals(offset(), other.offset()) && Objects.equals(factor(), other.factor())
&& Objects.equals(length(), other.length()) && Objects.equals(name(), other.name());
}
/**
* 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("CanSignal").add("MessageId", messageId()).add("IsBigEndian", isBigEndian())
.add("IsSigned", isSigned()).add("StartBit", startBit()).add("Offset", offset()).add("Factor", factor())
.add("Length", length()).add("Name", name()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "messageId":
return Optional.ofNullable(clazz.cast(messageId()));
case "isBigEndian":
return Optional.ofNullable(clazz.cast(isBigEndian()));
case "isSigned":
return Optional.ofNullable(clazz.cast(isSigned()));
case "startBit":
return Optional.ofNullable(clazz.cast(startBit()));
case "offset":
return Optional.ofNullable(clazz.cast(offset()));
case "factor":
return Optional.ofNullable(clazz.cast(factor()));
case "length":
return Optional.ofNullable(clazz.cast(length()));
case "name":
return Optional.ofNullable(clazz.cast(name()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function