0

Can Javers be used to calculate the differences using class/object like metamodels instead of concrete Java classes?

My research so far leads me to believe Javers differences only works on models which are realized as concrete Java classes.

Similarly with the java-object-diff library.


I have a metamodel in which a single model contains roughly similar information to what one gets using the Java Reflection APIs (i.e. Class, Field). I also have model object instances, which are similar to a Java Object (i.e. an instance of a class). Both the metamodel and model object instances are Java classes, but the classes themselves are general reused modeling classes and uninteresting themselves.

I'm expecting to have to do quite a bit of wiring to expose the details of the metamodel to the differencing algorithm, equivalent to what one gets from the Java Reflection API and the usual Java object semantics. Such as:

  • What is an entity?
  • What are an entities attributes?
  • What is the cardinality of an attribute? (e.g. one, many/collection/list/array).
  • What type is the attribute value, entity or non-entity (e.g. primitive). Is the attribute another entity or a non-entity (e.g. primitive)?
  • Provide a means to read the value of an attribute given an entity instance.
  • What is the definition of "identical"?
  • What is the definition of "equal"?
  • What is the definition of "comparable"?
  • Support complex correlation (e.g. a similarity metric) when differencing sets/collections, not just by standard "equality".

etc.

1 Answers1

0

JaVers uses a metamodel internally to compare user's objects. User's objects are mapped to Cdo abstraction. (see https://javers.org/javadoc_3.x/org/javers/core/metamodel/object/Cdo.html) and then Cdo instances are compared.

So, the whole diff algorithm is based on the metamodel. But, it's the JaVers' metamodel. Is JaVers ready to handle any kind of metamodel? Probably not.

Is JaVers ready to handle your metamodel? It's hard to say without seeing it, but I doubt.

What I can suggest, try to convert your metamodel to the JaVers' metamodel. Provide Cdo instances, for example CdoSnapshot and compare them.

Bartek Walacik
  • 3,386
  • 1
  • 9
  • 14