-
Enhancement
-
Resolution: Duplicate
-
P5
-
None
-
5.0
-
x86
-
windows_xp
A DESCRIPTION OF THE REQUEST :
I feel that there is a need for a 'property' keyword in the java language.
There is too many skeleton code that performs the same function over and over. example
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
JUSTIFICATION :
It would only be in the interest of the java language to have a 'property' keyword where one could specify the property name and let the compiler
generate the getters and setters, and only if needed override the default
behaviour.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
public property String name;
(the compiler would generate default getter and setter method stubs for the name attribute with public access, name would always be private, but could be combine with other access attributes) This would make the EJB3 POJO model also allot cleaner. When either a getter or setter does exist the compiler would use that instead.
---------- BEGIN SOURCE ----------
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
[becomes]
public property String name;
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Spending hours looking a getter and setter stub code.
I feel that there is a need for a 'property' keyword in the java language.
There is too many skeleton code that performs the same function over and over. example
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
JUSTIFICATION :
It would only be in the interest of the java language to have a 'property' keyword where one could specify the property name and let the compiler
generate the getters and setters, and only if needed override the default
behaviour.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
public property String name;
(the compiler would generate default getter and setter method stubs for the name attribute with public access, name would always be private, but could be combine with other access attributes) This would make the EJB3 POJO model also allot cleaner. When either a getter or setter does exist the compiler would use that instead.
---------- BEGIN SOURCE ----------
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
[becomes]
public property String name;
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Spending hours looking a getter and setter stub code.
- duplicates
-
JDK-8061409 Explicit (language) support for properties
-
- Closed
-