Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 317431 - Conversion of an enumeration fails
Summary: Conversion of an enumeration fails
Status: RESOLVED FIXED
Alias: None
Product: EMFT
Classification: Modeling
Component: Texo (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Martin Taal CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-21 08:50 EDT by Filip Hrbek CLA
Modified: 2010-08-03 13:35 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Hrbek CLA 2010-06-21 08:50:02 EDT
Conversion of an attribute whose type is an enumeration fails on ClassCastException when converting from POJO to EMF.

The converting method in org.eclipse.emf.texo.xml.ModelEMFConverter looks like this:

  protected Object convertEAttributeValue(final Object value, final EDataType eDataType) {
    if (value instanceof Enum<?>) {
      final EDataType enumDataType = getDataTypeOrBaseType(eDataType);
      Check.isInstanceOf(enumDataType, EEnum.class);
      final EEnum eeNum = (EEnum) enumDataType;
      for (final EEnumLiteral enumLiteral : eeNum.getELiterals()) {
        // the code generation template uppercases enum
        if (enumLiteral.getName().toUpperCase().equals(((Enum<?>) value).name())) {
          return enumLiteral;
        }
      }
    }

    ...
  }

Perhaps the value to return should be "enumLiteral.getInstance()" instead of the bare "enumLiteral"?
Comment 1 Martin Taal CLA 2010-08-03 13:35:23 EDT
This should be fixed in the latest build which is available now.

gr. Martin