Releases: Builderb0y/AutoCodec
Release list
Release 6.0.3
- Fixed performance issue with StackContextLogger calling toString() on objects before it has checked whether or not the message will actually be logged. In many cases, it wouldn't be, so the string concatenation involved was completely unnecessary.
- Fixed some delayed NPEs when other DynamicOps return null in unexpected places.
JsonOps.getMap()for example returns a MapLike which explicitly checks for JsonNull and substitutes a real null value instead.
Release 6.0.2
- Allow VersionedFixer to provide a default version when data does not specify a version. Default implementation throws an exception to match previous behavior.
- Fix VersionedFixer hard-coding the version key in appending stage.
Release 6.0.1
Fixed DataFactory not being implemented by DynamicOpsContext like it should've been.
Release 6.0.0
Main changes:
- Added an official data fixer system.
- Added an official data flavor, with its own ops.
See changes.md for a more detailed changelog.
Release 5.0.1
-
Fixed type formatting of annotations. The previous logic had the following issues:
- Attributes like
stringValue = "foo.bar.example"would be shortened tovalue = "example". This is undesirable for string literals. - Attributes like
doubleValue = 16.0would be shortened todoubleValue = 0. This is VERY undesirable for double literals. - Attributes like
classValue = foo.bar.Example.classwould be shortened toclassValue = class. This is EXTREMELY undesirable for class literals.
All 3 of these issues are now fixed.
- Attributes like
-
Added additional checks to AnnotationContainer to verify that the annotations you're asking about are actually available at runtime. It is easy to forget to annotate your annotations as
@Retention(RetentionPolicy.RUNTIME), and such un-annotated annotations will never be present on an AnnotationContainer unless you literally construct them manually by writing your own class which implements the annotation interface. Not very many people do this in my experience. As such, attempting to ask an AnnotationContainer "is this un-annotated annotation present?" is an indication that you may have forgotten to annotate your annotations as runtime-retained. As such, an AssertionError will now be thrown when asking an AnnotationContainer this question. I chose an AssertionError because the fix for this problem requires modifying your code; it is not correctable at runtime. For performance reasons, these checks are only performed when asserts are enabled. If for any reason it is unknown at compile-time whether or not an annotation is runtime-retained, an additional helper method is also provided to check this for you.
Release 5.0.0
See changes.md for a list of things that changed in V5. There are a lot of changes. I apologize in advance for the amount of work it'll be for anyone reading this to port from V4 to V5.
Release 4.12.1
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.
Release 4.12.0
- Updated to DFU 7.
- AutoCodec now supports the creation of MapCodec's.
- 3rd-party AutoEncoder's/AutoDecoder's/AutoCoder's may need to override the new method getKeys() in order to be usable as MapCodec's.
- AutoEncoder's/Decoder's/Coder's which do not override getKeys() will still be usable as Codec's, but not as MapCodec's.
Release 4.11.0
- Fixed self-referencing types stack overflowing when calling toString() on them.
For example,public <C extends Comparable<C>> void foo(C c) {}.
Attempting to resolve C as a declaration of foo's declaring class would create a self-referencing type,
and attempting to call toString() on a ReifiedType would throw a StackOverflowError.
This has now been fixed. - ReifiedType.unresolvableVariable() now takes the TypeVariable which failed to be resolved as a parameter, instead of the ReifiedType representing its upper bound.
The reasons for this breaking change are as follows:- The old method had no sanity checking that the provided bound extends the TypeVariable's declared bound.
- The old method left the unresolvable variable on the ReifiedType as null, which violates the
spec which says the variable should be non-null when the classification is UNRESOLVABLE_VARIABLE. - Without a TypeVariable to reference, the old method could not inherit annotations from that type variable.
- Added Intern annotation for String decoding.
- RecordCoder now sanity checks that fields with the same name as a parameter in the chosen constructor also have the same generic type as that parameter.
- ReifiedType now has an uncheckedCast() method, so you don't need quite as many SuppressWarnings's anymore.
- ReifiedType.from(Class<?>) is now cached.
- EncodeInline/MultiLine/SingletonArray.INSTANCE now override equals(), hashCode(), and toString().
Release 4.10.0
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
@Nullableannotation fromAutoCodec.decode()andDecodeContext.decodeWith(), since if you have anAutoDecoder<@NotNull T>, then it makes no sense for it to return a null value when decoding.@Nullabledoes however remain onAutoDecoder.decode(). - Added the
@Aliasannotation, 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 aStringinstead of aSupplier<String>. - Deprecated exception constructors which take a
Stringwhen another constructor which taks aSupplier<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
KeyDispatchCoderandLookupCoder, 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
MemberCollectorthrows an exception and triggers error logging OR if the logger just prints everything.