FasterXML / jackson-dataformats-binary

Uber-project for standard Jackson binary format backends: avro, cbor, ion, protobuf, smile
Apache License 2.0
316 stars 136 forks source link

Default `AvroModule` configuration to use both Jackson and Avro `AnnotationIntrospector` #80

Closed cowtowncoder closed 7 years ago

cowtowncoder commented 7 years ago

It seems sensible to allow configuration of annotation introspector(s) to use with AvroModule, to allow for using Avro and/or Jackson introspectors. Although there are many ways to achieve this, it seems perhaps sensible to add three levels of configurability:

  1. Default setting of just inserting AvroAnnotationIntrospector so that it has precedence, but defaults to whatever basic ObjectMapper (like AvroMapper) has otherwise configured. Usually this means "Avro annotations if present; otherwise Jackson" setting.
  2. Allow explicit definition of introspector to register; if so, use that to replace whatever mapper has
  3. Handle both (1) and (2) within an overridable method, called when module is being registered: for more complex cases this method may be just overridden by sub-classing AvroModule
cowtowncoder commented 7 years ago

Added method withAnnotationIntrospector; default introspector is AvroAnnotationIntrospector but it can be removed (set null) or changed.