Johan youve been doing a lot of profiling havent you? Last time i looked instanceof was a hotspot with 1% total runtime. So im not that worried, but maybe you have better stats.
Instanceof is not measureable. So not worries there no.
I like the current idea though!
But don't know why we should have 2 interfaces why not just one?
IVersionable (or something)
Change getUndoChange()
And you are done!
Model object can make a change when the modelObject is set.
And the PersistentObjectModel does it when the id is set and so on.
i don't get what you mean by the IModelVersionable. What is exactly the difference between that and the modelobject?
Because if the Model reference itself changes (so in component) thent it is components problem to make the change.
And it already does that:
if (this.model != model)
{
addStateChange(new ComponentModelChange( this.model));
this.model = model;
Currently the problem is also that what happens now of you don't do:
Component.setModelObject() but Component.getModel().setObject() or if it is a specialized model: ((CastTo)getModel).setId(id)
Then we don't go through setModelObject and modelChanging is never called.
But if we really also want to fix that then models must be standalone. And we don't need that interface but they should be able to record that change to the page somehow.
I think i still prefer it simple:
IVersionable (or something)
Change getUndoChange()
And use that on the place where we now make a clone.
johan