FasterXML / jackson-datatypes-collections

Jackson project that contains various collection-oriented datatype libraries: Eclipse Collections, Guava, HPPC, PCollections
Apache License 2.0
79 stars 53 forks source link

Triple support #85

Closed yawkat closed 3 years ago

yawkat commented 3 years ago

Eclipse-collections added a Triple class in version 10 and I want to add support for it. This should be straight-forward in principle.

The only issue is that because EC upgrades have some (albeit small) incompatibilities, I don't want to require a newer version, or require the presence of the new class. @cowtowncoder , what is the usual way to add a (de)serializer only if a certain class is present? My first guess would be just catching NoClassDefFoundError, but maybe there's existing machinery.

cowtowncoder commented 3 years ago

There isn't really much in way of general-purpose machinery, but yes, technique used is to isolate functionality that relates to new class into wrapper class, and then try to load that class, catch exception. Usually helper class implements some safe interface through which methods are dispatches (access to (de)serializer instances, directly, or to lookup methods)

Jackson-databind package com.fasterxml.jackson.databind.ext has some of these; not sure if they are good examples but seem to work.

yawkat commented 3 years ago

I've added this to 2.13 for now. I don't think backporting to 2.12 is a good idea, because the changed dependency version could break builds for some people (though explicitly using an older version and ignoring the transitive dep through jackson-datatype-eclipse-collections still works), and this feature isn't urgent enough to warrant that. Do you agree?

yawkat commented 3 years ago

Merged to 3.0 as well, with some adjustments in the code to use createContextual, similar to how you ported PairInstantiator.

cowtowncoder commented 3 years ago

Agreed wrt 2.12: dependency change, added functionality does sound more like minor version change.

One quick ask: could add a reference to release-notes/VERSION-2.x as well? And if so, maybe on https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.13 as well -- although I can do latter based on release notes.

yawkat commented 3 years ago

Done in 3913800effe8f35bdb41eb14bc2155f226a9733e and e919050e4ecf976bc1b2c328e9b127c696f30abd. I don't have write access to the wiki, so probably easier if you do it than making a PR :)