Domanda

I have an EMF model and I want to provide a read-only representation for some of the objects in the model (in order to prevent unwanted changes being made to the model).

Is there a way to provide this (maybe some kind of a read-only proxy/facade for EObjects)? I don't want to solve this by just not generating setters. In fact, I want to avoid changing the existing model classes as far as possible. Instead, I'd rather like to add something to it...

Thanks in advance, Ingo

È stato utile?

Soluzione

What approach you take is probably going to depend on the bigger picture of what you are trying to achieve.

If you want a framework that does the work for you EMF-Transaction is worth looking at. Access to the model is achieved through transactions and there is support for read-only transactions.

If you want something lighter you could get your emf objects to implement read-only interfaces. It shouldn't be too much work to add a template to automatically generate these for you if you wished.

Tas

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top