Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 317431

Summary: Conversion of an enumeration fails
Product: [Modeling] EMFT Reporter: Filip Hrbek <filip.hrbek>
Component: TexoAssignee: Martin Taal <mtaal>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

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