Question

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?

Was it helpful?

Solution

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()

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top