Pergunta

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?

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top