Skip to content

Release 4.10.0

Choose a tag to compare

@Builderb0y Builderb0y released this 23 Jul 02:29
· 6 commits to master since this release

This update contains BREAKING CHANGES to how @Default<type> annotations are handled internally! This does not affect the annotations themselves or their usages, but it does affect anyone who previously relied on DefaultValue, DefaultDecoder, DefaultCoder, or MultiFieldEncoder.FieldStrategy.

More specifically, DefaultValue now handles all the encoding and decoding logic, and DefaultDecoder simply delegates to it. A new class, DefaultEncoder, also delegates to it. DefaultCoder has been REMOVED. The type hierarchy of DefaultValue was expanded to support the new @DefaultObject annotation, and was split into PrimitiveDefaultValue and ObjectDefaultValue. Several methods that applied to primitives did not apply to objects, and were REMOVED from DefaultValue. DefaultValue.forType() still exists, but takes additional arguments now. MultiFieldEncoder.FieldStrategy also no longer contains a defaultValue field, and will check for emptyness of the encoded value instead.

Other changes:

  • Removed the @Nullable annotation from AutoCodec.decode() and DecodeContext.decodeWith(), since if you have an AutoDecoder<@NotNull T>, then it makes no sense for it to return a null value when decoding. @Nullable does however remain on AutoDecoder.decode().
  • Added the @Alias annotation, to allow a decoded field to match more than one encoded field.
  • AutoCodec (the library, not the class) is now backwards-compatible with old versions of DFU where DataResult.error() took a String instead of a Supplier<String>.
  • Deprecated exception constructors which take a String when another constructor which taks a Supplier<String> also exists. these deprecated constructors aren't going anywhere, they're just deprecated to issue a compile-time warning that you might have used a different constructor than you intended to.
  • Added KeyDispatchCoder and LookupCoder, for anyone who wants those.
  • Added better logging to factories which query fields or methods in the decoded type, however this logging will only be visible if the MemberCollector throws an exception and triggers error logging OR if the logger just prints everything.