Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Generating final getters and setters
Generating final getters and setters [message #893544] Wed, 04 July 2012 14:00 Go to next message
Jean Couillaud is currently offline Jean CouillaudFriend
Messages: 11
Registered: July 2009
Junior Member
Hi,

If I want to be sure that my setters and my getters won't be redefined, it seems I can't rely on eclipse's generation.
AFAIK, there is no way to change the way eclipse generates the signature of getters and setters so as to generate the following code for instance :
public final void setProperty(final String property) {
 this.property = property;
}

It's a pain in the *** to change all the getters and setters so as to be sure that they won't be overriden.

Am I missing something about code templates ? getter/setter generation ?

Exemple of a change that could cause problems :
public class A extends Api {
 public void setProperty(final String property) {
  if (property.length() == 0) {
   property = null; // or anything else
  }
  setProperty(property);
 } 
}
Re: Generating final getters and setters [message #893551 is a reply to message #893544] Wed, 04 July 2012 14:18 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 04.07.2012 16:00, Jean Couillaud wrote:
> Hi,
> If I want to be sure that my setters and my getters won't be
> redefined, it seems I can't rely on eclipse's generation.
> AFAIK, there is no way to change the way eclipse generates the
> signature of getters and setters so as to generate the following code
> for instance :
Source > Generate Getters and Setters... wizard allows to set it.

Dani
> public final void setProperty(final String property) {
> this.property = property;
> }
> It's a pain in the *** to change all the getters and setters so as to
> be sure that they won't be overriden.
>
> Am I missing something about code templates ? getter/setter generation ?
>
> Exemple of a change that could cause problems :
> public class A extends Api {
> public void setProperty(final String property) {
> if (property.length() == 0) {
> property = null; // or anything else
> }
> setProperty(property);
> } }
Re: Generating final getters and setters [message #893575 is a reply to message #893551] Wed, 04 July 2012 16:20 Go to previous message
Jean Couillaud is currently offline Jean CouillaudFriend
Messages: 11
Registered: July 2009
Junior Member
Ermmm ... strange, I always thought that it meant final for setter parameters ...
sorry for bothering the forum with such a dumb question
Previous Topic:How to add column dynamically in birt report table using scripted dataset
Next Topic:How to get an object reference from IVariable or IJavaVariable
Goto Forum:
  


Current Time: Fri Apr 26 23:56:12 GMT 2024

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

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

Back to the top