BraintagsGmbH/vertx-pojo-mapper

data-versioning and conversion

remi128 opened this issue · 3 comments

As follow up of #84 implementation of an abstract IObserver, which is responsible for data version conversion. The observer can be added to afterLoad and / or beforeSave.

responsible parts:

  • Interface IMapperVersion contains property mapperVersion.

  • annotation Entity contains property version, which defines the current version of a mapper

  • annotation VersionConverter contains the list of existing converters of a mapper

  • interface IDataConverter defines the destination version and a method to convert data of a record

A mapper can receive the annotation "MapperVersion", where inside the current version of the mapper is defined. This annotation can be set only for mapper classes, which extend IMapperVersion.
New instances of this mapper automatically get the current version, which is defined by the annotation "MapperVersion" of the mapper.

When the observer is executed, it checks the current version. If it is different than the current version defined by the mapper, it searches for defined instances of IDataConverter, sorts them based on the version-definition and executes them for the given instance.

additional idea: an entry of the annotation VersionConverter shall contain a hash of the mapper, which might be calculated from the information inside IMapper. If the class changes and no suitable entry is found inside VersionConverter, the system should throw an exception.

pull request

finished, merged