Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [TEXO] Problem with ClassCastException in ModelPackage
[TEXO] Problem with ClassCastException in ModelPackage [message #559199] Wed, 15 September 2010 19:01 Go to previous message
Mark Hoffmann is currently offline Mark Hoffmann
Messages: 95
Registered: July 2009
Location: Jena
Member
Hi,

I created a code-gen.annotationsmodel from my ecore to change the package path.
The enums will not saved in the correct folder from the annotionsmodel, but the package definition in the generated code ist correct.

In my model if have a Contact class and an enum called ContactType. If I call ModelPackage.INSTANCE I get the following exception:
Caused by: java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EEnumImpl cannot be cast to org.eclipse.emf.ecore.EClass
	at de.sim.texo.model.common.person.PersonModelPackage.getContactEClass(PersonModelPackage.java:787)
	at de.sim.texo.model.common.person.PersonModelPackage.initialize(PersonModelPackage.java:405)
	at de.sim.texo.model.common.person.PersonModelPackage.<clinit>(PersonModelPackage.java:376)
	... 31 more


The generated code looks like this:
	/**
	 * Returns the {@link EClass} '<em><b>Contact</b></em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @return an instance of the {@link EClass} '<em><b>Contact</b></em>' 
	 * @generated
	 */
	public EClass getContactEClass() {
		return (EClass) getEPackage().getEClassifiers().get(
				CONTACT_CLASSIFIER_ID);
	}

I debugged a little bit. This method return the ContactType instead of the Contact.

In my ecore looks like this:
<eClassifiers xsi:type="ecore:EClass" name="Contact">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" lowerBound="1" eType="#//ContactType"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="context" lowerBound="1"
        eType="#//ContactContextType" defaultValueLiteral="PRIVATE"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="value" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ELong"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="note" eType="ecore:EClass common.ecore#//Note"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EEnum" name="ContactType">
    <eLiterals name="EMAIL"/>
    <eLiterals name="PHONE" value="1"/>
    <eLiterals name="MOBILE" value="2"/>
    <eLiterals name="FAX" value="3"/>
    <eLiterals name="WWW" value="4"/>
    <eLiterals name="MESSENGER" value="5"/>
    <eLiterals name="OTHER" value="6"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EEnum" name="ContactContextType">
    <eLiterals name="PRIVATE"/>
    <eLiterals name="BUSINESS" value="1"/>
    <eLiterals name="OTHER" value="2"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="ContactList">
    <eStructuralFeatures xsi:type="ecore:EReference" name="contacts" upperBound="-1"
        eType="#//Contact"/>
  </eClassifiers>


Does anybody know this problem?

Regards,
Mark

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:[EEF] Ant task to generate models and code
Next Topic:[EEF] Model reload
Goto Forum:
  


Current Time: Mon May 20 03:24:59 EDT 2013

Powered by FUDForum. Page generated in 0.05086 seconds