Skip to content

Release 4.12.1

Choose a tag to compare

@Builderb0y Builderb0y released this 10 Aug 18:19

Added new overloads to AutoCodec to wrap DFU Encoder's, Decoder's, and Codec's which are not null-safe. A null-safe handler is one which allows null or empty inputs, and returns a null or empty output sanely. If a handler is not null-safe, this means it returns an error-type DataResult instead, which is not always desirable. This is particularly the case when trying to use a wrapped Codec to decode a @VerifyNullable type. Ideally, all handlers should be null-safe since AutoCodec is designed around verifiers handling the task of sanity checking. But this is not the design philosophy of ordinary DFU.

This release also comes with a 2nd overload for the aforementioned methods to allow omission of the allowPartial flag. To sum up, there are now 3 valid overloads for these wrapping methods:

  • wrapDFUEncoder(Encoder encoder)
  • wrapDFUEncoder(Encoder encoder, boolean allowPartial)
  • wrapDFUEncoder(Encoder encoder, boolean allowPartial, boolean nullSafe)

Where not specified, allowPartial now defaults to false because this is what I've been passing in so far. I don't think there are very many DFU handlers which sanely handle null or empty inputs, so it would make sense for nullSafe to default to false, but this could change behavior of existing usages. So I made it default to true instead, as this is guaranteed to match the behavior of old versions of AutoCodec.