Bug 389807 - [Xtend] Attribute names with a first single lower case letter (camel case problem)
Summary: [Xtend] Attribute names with a first single lower case letter (camel case pro...
Status: NEW
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.3.1   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-18 08:09 EDT by Boris Brodski CLA
Modified: 2017-02-21 09:35 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Brodski CLA 2012-09-18 08:09:29 EDT
The following code produces an error:


package test;

@Data
public class SingleLetterCamelCase {
	int a;
	Integer aBoxed;
	Integer abBoxed;
}

class Test {
	def a() {
		var SingleLetterCamelCase a
		println a.a
		println a.aBoxed // Error: The method aBoxed is undefined for the type Test
		println a.ABoxed // OK
		println a.abBoxed
	}
}


The problem is, that the getter "getABcde" maps to the attribute "ABcde" and not to the "aBcde".
Comment 1 Sven Efftinge CLA 2012-11-09 04:14:20 EST
From a JavaBeans perspective it's correct that the property name of getABoxed is 'ABoxed'.
We could make the getter and setter generation to produce 'getaBoxed' instead, i.e. don't capitalize the first char if the second is upper case.
Any thoughts?
Comment 2 Sebastian Zarnekow CLA 2012-11-09 04:31:40 EST
I think it's important to be compliant with the rules of java.beans.Introspector.decapitalize(String).

getaBoxed looks alien to me. We could issue a warning on aBoxed in the lines of 'discouraged property name' and accept that one has to use this.ABoxed afterwards.
Comment 3 Sebastian Zarnekow CLA 2012-11-09 05:34:16 EST
A offline discussion convinced me that 

@Property Object aThing

should yield getaThing and setaThing but issue an optional warning on the name in the sense of 'will produce unexpected accessor names'
Comment 4 Boris Brodski CLA 2012-11-09 06:36:00 EST
What actually stops us from generating getABoxed() getter, but access it through aBoxed property in Xtend?
Comment 5 Sebastian Zarnekow CLA 2012-11-09 07:25:17 EST
Compliance with the JavaBeans convention
Comment 6 Boris Brodski CLA 2012-11-09 08:17:07 EST
Thanks! I see it now.
Comment 3 is the best solution.
Comment 7 Sven Efftinge CLA 2013-09-12 09:59:22 EDT
We cannot change @Property and also I think we should stick to JavaBeans spec (I don't remember the conclusion of our offline discussion...)