Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354901 - MOF Model needs to tell if an enumeration entry has a value
Summary: MOF Model needs to tell if an enumeration entry has a value
Status: CLOSED DUPLICATE of bug 354861
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-16 20:17 EDT by Matt Heitz CLA
Modified: 2017-02-23 14:15 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***