What does Eclipse consider as a "simple getter" or a "simple setter"?
I use the Eclipse debugger on a regular basis and this has always bugged
me about the IDE. Step filtering is such an invaluable tool, that way I'm
not stepping into classes that does not have source code or I'm simply not
interested in. However Eclipse isn't getting it right for most cases. In
particular, there are options to "Filter simple getters" and "Filter
simple setters".
I might use a getter that just simply returns the value of a member variable.
private String value;
public String getValue()
{
return value;
}
Or perhaps a getter that lazily instantiates an expensive object.
private IObjectFactory instance;
public IObjectFactory getInstance()
{
if (instance == null)
instance = ObjectFactory.createFactory();
return instance;
}
I might use a setter that just sets the value of a member variable.
private String value;
public void setValue(String value)
{
this.value = value;
}
I might want to support fluent syntax.
private String value;
public ObjectFactory setValue(String value)
{
this.value = value;
return this;
}
Or perhaps do some validation or event triggering.
private String user;
public void setUser(String user)
{
if (StringUtils.isBlank(user))
throw ExceptionHelper.argumentNull("user");
this.user = user;
}
private String title;
public void setTitle(String title)
{
if (!StringUtils.equals(this.title, title))
{
this.title= title;
onPropertyChanged("title", title);
}
}
And for every single one of these uses, stepping into code using eclipse
steps into these methods...
What does Eclipse consider as a "simple getter" or a "simple setter"?
No comments:
Post a Comment