RuedigerMoeller / fast-serialization

FST: fast java serialization drop in-replacement
Apache License 2.0
1.59k stars 247 forks source link

Support for serializers for interfaces. #181

Closed odd closed 7 years ago

odd commented 7 years ago

Adds the ability to register serializers for interfaces (in addition to classes). To find the most specific serializer for a class C all ascendants of C (both superclasses and interfaces) are searched in order of their specificity (i.e. a more specific ancestor is checked before a less specific one). The specificity of a class is defined as follows:

  1. null has specificity 0
  2. java.lang.Object has specificity 0
  3. an interface without any extends clause has specificity 1
  4. a class or interface has a specificity of: 1 + the specificity of the superclass + the sum of the specificity of the implemented interfaces.
RuedigerMoeller commented 7 years ago

Hi, thanks for your submission. Is it an optional extension or does it sideeffect also on preregistered serializers (~backward compatibility issues) ?

odd commented 7 years ago

Hi, it is intended to work as before for all class based serializers since the lineage of a class will include all superclasses in the same order as the current traversal via getSuperclass(). The new lineage based traversal will however also include any interfaces (in order from most to least specific) so if a serializer is registered for an interface that is more specific than a superclass the one for the interface will be found first and thus used. So if no serializers are registered for any interfaces it will function in the same way as it does now (at least that's the idea).

RuedigerMoeller commented 7 years ago

I'll give it a shot :) . I'll start providing a "stable-branch" so I can be less picky regarding pull requests. Thanx for supporting :)

RuedigerMoeller commented 7 years ago

will be included in 2.49