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

Bug 354901

Summary: MOF Model needs to tell if an enumeration entry has a value
Product: z_Archived Reporter: Matt Heitz <mheitz>
Component: EDTAssignee: Project Inbox <edt.mofmodel-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P1 CC: jvincens, pharmon
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Matt Heitz CLA 2011-08-16 20:17:17 EDT
If an enumeration entry isn't given a value by the user, the JavaScript generator's EnumerationTemplate will assign it a numeric value based on its position.  In other words, the two enumerations below will be generated the same way.

enumeration Example1
  shoe, bug, pickle
end

enumeration Example2
  shoe = 1, bug = 2, pickle = 3
end

I wanted to duplicate this in the Java generator.  However when I looked at the JS generation code, I found that it decides an enumeration entry wasn't given a value by testing if EEnumLiteral.getValue() returns zero.

That's not good.  It means it's impossible to have an enum entry with the value zero.  This enumeration will be generated the same as the two above:

enumeration Example3
  shoe = 0, bug = 0, pickle = 0
end

(Yes, it's an absurd example, but we ought to let people set one of the entries to zero.)

The model should either store a default value in the EEnumLiteral based on its position, or there should be a method like EEnumLiteral.hasValue() for the generators to call.

Until the model changes, I'm going to make the Java generator behave like the JS generator.
Comment 1 Paul Harmon CLA 2011-10-25 10:56:40 EDT
I am marking this a a duplicate of bug 354861. I am doing a major overhaul of the validation and constant value code

*** This bug has been marked as a duplicate of bug 354861 ***