tree-ware / tree-ware-kotlin-core

Apache License 2.0
1 stars 0 forks source link

Implement a difference operator #136

Closed deepak-nulu closed 2 years ago

deepak-nulu commented 2 years ago

The difference operator must compute the difference between two input tree-ware trees (which are both based on the same meta-model). The output must specify what must be added, updated, and deleted to/from the first input tree to get the second input tree.

The implementation is free to represent the output using one, two, or three trees, whichever is easier. If the output is one or two trees, the aux data of set-requests must be used to indicate whether a node has been added (CREATE), updated (UPDATE), or deleted (DELETE).

deepak-nulu commented 2 years ago

To detect if an association has been updated, the difference operator requires the matches() method for associations to be implemented, but it currently has a TODO() stating that an equals operator is needed (strictly speaking, it would have to be an equals function not an operator because it would not be returning a model tree).

Instead of a separate equals function, the difference operator itself can be used on the association values since they are (model paths represented as) model trees.

NOTE: the difference operator (or any other operator) should NOT be used in Model.kt or MutableModel.kt, so the comparison of the association values using the difference operator must be done in the difference operator itself.