|
|
|
|
|
|
|
Re: Dynamic Model: invalid classifier [message #930371 is a reply to message #930349] |
Tue, 02 October 2012 08:50 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
Erdal,
That code looks like this:
public EObject create(EClass eClass)
{
if (getEPackage() != eClass.getEPackage() || eClass.isAbstract())
{
throw new IllegalArgumentException("The class '" +
eClass.getName() + "' is not a valid classifier");
}
for (List<EClass> eSuperTypes = eClass.getESuperTypes();
!eSuperTypes.isEmpty(); )
{
EClass eSuperType = eSuperTypes.get(0);
if (eSuperType.getInstanceClass() != null)
{
EObject result =
eSuperType.getEPackage().getEFactoryInstance().create(eSuperType);
((InternalEObject)result).eSetClass(eClass);
return result;
}
eSuperTypes = eSuperType.getESuperTypes();
}
return basicCreate(eClass);
}
So eSuperType.getInstanceClass() != null must be true for you to have a
problem...
If your IMyInstance is in a different package and you're referring to
the generated package instance for this EClass, you won't be able to
create dynamic instances of it. Such a dynamic instance would have to
implement the generated interface, but there exists no implementation
class that does so...
On 02/10/2012 10:25 AM, Erdal Karaca wrote:
> If I try to create an instance of A or B using the 'default dynamic
> EFactory', the ecore internals will delegate to the EFactory of
> IMyInstance and since that is an interface and cannot be instantiated
> I will get the invalid classifier.
>
> E.g. 'pak' is the EPackage of the dynamic model:
>
>
> EClass a = EcoreFactory.eINSTANCE.createEClass();
> a.setName("A");
> a.getESuperTypes().add(RegularPackage.Literals.IMyInterface);
> pak.getEClassifiers().add(a);
>
> pak.getEFactoryInstance().create(A);
>
>
>
> Do I miss something else?
>
> Ed Merks wrote on Tue, 02 October 2012 04:15
>> So what exactly is the problem then? Of course you can't instantiate
>> an abstract class, but you should be able to instantiate an A or a B.
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03389 seconds