dcsimg
Customizing eclipse generated getters and setters
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Sunday, November 26, 2006 07:47 AM

i have a simple java class like this public class Event { private String _name = null; } for the above class if i try to generate getters and setters.. this is the output i see public String get_name() { return _name; } public void set_name(String _name) { this._name = _name; } but this is my desired output public String getName() { return _name; } public void setName(String name) { _name = name; } Can anyone pls help me on this!! am new to eclipse IDE. This is supported in VisualSlick editor. Am not sure.. how    More>>
			
i have a simple java class like this

public class Event
{
private String _name = null;
}

for the above class if i try to generate getters and setters.. this is the output i see

public String get_name()
{
return _name;
}

public void set_name(String _name)
{
this._name = _name;
}

but this is my desired output

public String getName()
{
return _name;
}

public void setName(String name)
{
_name = name;
}

Can anyone pls help me on this!!
am new to eclipse IDE.

This is supported in VisualSlick editor.
Am not sure.. how we can do it in eclipse

Thanx In Advance

   <<Less

Re: Customizing eclipse generated getters and setters

Posted By:   WarnerJan_Veldhuis  
Posted On:   Sunday, November 26, 2006 01:53 PM

I would change the name of the field to name instead of _name. That would do the trick. if you have trouble identifying local variables (parameters) vs object variables, prefix the field with this..
public void setName( String name) {
this.name = name;
}

Who invented the underscore anyway???
About | Sitemap | Contact