public static final class Codec extends GenericDataTypeCodec<BACnetActionCommand> {
@Override
public Class<BACnetActionCommand> getType() {
return BACnetActionCommand.class;
}
@Override
public BACnetActionCommand decode(SerializationContext context, UaDecoder decoder) {
UInteger encodingMask = decoder.readUInt32("EncodingMask");
long encodingMaskValue = encodingMask.longValue();
UInteger deviceIdentifier = null;
if ((encodingMaskValue & (1L << 0)) != 0) {
deviceIdentifier = decoder.readUInt32("deviceIdentifier");
}
UInteger objectIdentifier = decoder.readUInt32("objectIdentifier");
BACnetPropertyIdentifier propertyIdentifier = decoder.readEnum("propertyIdentifier", BACnetPropertyIdentifier.class);
UInteger propertyArrayIndex = null;
if ((encodingMaskValue & (1L << 1)) != 0) {
propertyArrayIndex = decoder.readUInt32("propertyArrayIndex");
}
Variant propertyValue = decoder.readVariant("propertyValue");
UByte priority = null;
if ((encodingMaskValue & (1L << 2)) != 0) {
priority = decoder.readByte("priority");
}
UInteger postDelay = null;
if ((encodingMaskValue & (1L << 3)) != 0) {
postDelay = decoder.readUInt32("postDelay");
}
Boolean quitOnFailure = decoder.readBoolean("quitOnFailure");
Boolean writeSuccessful = decoder.readBoolean("writeSuccessful");
return new BACnetActionCommand(deviceIdentifier, objectIdentifier, propertyIdentifier, propertyArrayIndex, propertyValue, priority, postDelay, quitOnFailure, writeSuccessful);
}
@Override
public void encode(SerializationContext context, UaEncoder encoder, BACnetActionCommand value) {
long encodingMaskValue = 0L;
if (value.getDeviceIdentifier() != null) {
encodingMaskValue |= (1L << 0);
}
if (value.getPropertyArrayIndex() != null) {
encodingMaskValue |= (1L << 1);
}
if (value.getPriority() != null) {
encodingMaskValue |= (1L << 2);
}
if (value.getPostDelay() != null) {
encodingMaskValue |= (1L << 3);
}
encoder.writeUInt32("EncodingMask", Unsigned.uint(encodingMaskValue));
if (value.getDeviceIdentifier() != null) {
encoder.writeUInt32("deviceIdentifier", value.getDeviceIdentifier());
}
encoder.writeUInt32("objectIdentifier", value.getObjectIdentifier());
encoder.writeEnum("propertyIdentifier", value.getPropertyIdentifier());
if (value.getPropertyArrayIndex() != null) {
encoder.writeUInt32("propertyArrayIndex", value.getPropertyArrayIndex());
}
encoder.writeVariant("propertyValue", value.getPropertyValue());
if (value.getPriority() != null) {
encoder.writeByte("priority", value.getPriority());
}
if (value.getPostDelay() != null) {
encoder.writeUInt32("postDelay", value.getPostDelay());
}
encoder.writeBoolean("quitOnFailure", value.getQuitOnFailure());
encoder.writeBoolean("writeSuccessful", value.getWriteSuccessful());
}
}