Domanda

I want to create a new EObject, but by default the constructor is protected. Is there a way to overcome that and create a new instance of EObject?

È stato utile?

Soluzione

EMF uses the factory pattern. Please try EcoreFactory.eInstance.createEObject().

If you want to instantiate other objects that implement EObject, you'll have to use the respective factory for your own EPackage. The code should read MyPackFactory.eInstance.createObject() where MyPackFactory should be replaced by your concrete factory and createObject() has to be replaced by the type that you want to instantiate, e.g. createObjectValue()

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