Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想创建一个新的EObject,但默认情况下构造函数是受保护的。有没有办法克服这个问题并创建一个新的实例EObject?
EObject
EMF 使用工厂模式。请尝试EcoreFactory.eInstance.createEObject()。
EcoreFactory.eInstance.createEObject()
如果要实例化实现 EObject 的其他对象,则必须为自己的 EPackage 使用相应的工厂。代码应读取应由您的具体工厂替换的位置,并且MyPackFactory.eInstance.createObject()必须替换为您要实例化的类型,例如MyPackFactorycreateObject()createObjectValue()
MyPackFactory.eInstance.createObject()
MyPackFactory
createObject()
createObjectValue()