frizbog / gedcom4j

Java library for reading/writing genealogy files in GEDCOM format
http://gedcom4j.org
54 stars 36 forks source link

ModelElements need copy constructors or clone() implementation or something like it #156

Closed frizbog closed 8 years ago

frizbog commented 8 years ago

In order to make before/after copies of objects during validation and autorepair, it would be necessary to be able to make a deep copy of an object prior to repairing it. The model objects currently do not support this.

frizbog commented 8 years ago

Branch v4-development

Psyches commented 7 years ago

FWIW, I guess another option would've been to just ensure the model is serializable - some form of which is nice anyway. It requires less "in the code" support for copying, and semantics for re-attaching tree cuts would (largely) be outside the model. Then the model elements only need declare transient items where the cuts are made (to prevent one thread from pulling in the whole ball of yarn).

Anyway, this approach worked well for me a few months ago, and helped minimize or eliminate copy support throughout the model hierarchy. Then, before and after images only need serialization and buffer storage, and reconstitution is only needed on-demand. For that matter, a serdes mechanism based on GEDCOM parser/emitter could also make sense. Then the buffers would be GEDCOM text rather than java binary, and either Externalizable or one of the XML/JSON-style serdes approaches could be taken.