Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » CamelCase in EMF generated Getter/Setter names
CamelCase in EMF generated Getter/Setter names [message #1747210] Thu, 10 November 2016 18:09 Go to next message
Thorsten Hake is currently offline Thorsten HakeFriend
Messages: 7
Registered: November 2012
Junior Member
I noticed that the pattern for generating EMF getter/setter method names is not the same pattern as it is used in the eclipse function "Source->Generate Getters and Setters...".

Example: A feature named "iFeature"
EMF generated method names: getIFeature/setIFeature (starting with a capital letter I)
Eclipse "Generate Getters and Setters..." function generated names: getiFeature/setiFeature (starting with a lower-case letter i)

Does anybody know if this is on purpose? The EMF naming leads to problems with tools that rely on deriving the property name from the getter/setter method names by calling https://docs.oracle.com/javase/7/docs/api/java/beans/Introspector.html#decapitalize(java.lang.String).

[Updated on: Thu, 10 November 2016 18:11]

Report message to a moderator

Re: CamelCase in EMF generated Getter/Setter names [message #1747239 is a reply to message #1747210] Fri, 11 November 2016 08:08 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
To me getiFeature doesn't look right and certainly we won't change the pattern we've been using for 15 years. Given EMF generates code already, I'm not sure why the ones Eclipse generates from variable names matters in this context. Yes the naming patterns we use are not accidental. For example we want to be able to generate getID and getURL and use the feature name iD and uRL for that purpose.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: CamelCase in EMF generated Getter/Setter names [message #1747252 is a reply to message #1747239] Fri, 11 November 2016 09:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Indeed. It seems unreasonable to expect a 'pretty-name' from perspective A to be compatible with perspective 'B'. The EMF GenModel controls the conversions, you could override them, but much more importantly you can re-use the GenModel utilities. Or rather you SHOULD reuse them since every time you attempt to use your intuition to recode a GenModel conversion, you ensure that your intuitive code will have problems with corner cases and EMF bug fixes.

Regards

Ed Willink
Re: CamelCase in EMF generated Getter/Setter names [message #1747581 is a reply to message #1747252] Wed, 16 November 2016 08:48 Go to previous message
Thorsten Hake is currently offline Thorsten HakeFriend
Messages: 7
Registered: November 2012
Junior Member
Thanks for your answers and thoughts on this topic. I was only wondering because the current generation pattern is incompatible with the Java Beans specification (see Section 8.8 Capitalization of inferred names - http://download.oracle.com/otn-pub/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/beans.101.pdf?AuthParam=1479286078_cac2cbf857db719198878dce3bae2e98).

But I guess it was never a goal of EMF to implement the Java Beans specification. Anyway, thanks again Smile
Previous Topic:Adding AnyType to AnyType Feature Map
Next Topic:[CDO] Security PackageFilter and ClassFilter
Goto Forum:
  


Current Time: Fri Apr 19 08:52:00 GMT 2024

Powered by FUDForum. Page generated in 0.02525 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top