How can I tell (if ever) Eclipse to make a single line for a getter or setter when using auto formatting?
public User getUser() {
return user;
}
to:
public User getUser() { return user; }
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you don’t like all the boilerplate which Java forces you to write, you might be interested in Project Lombok as an alternative solution.
Instead of trying to format your code to minimize the visual impact of getters and setters, Project Lombok allows them to be added by the compiler behind the scenes, guided by annotations on your class’s fields.
Instead of writing a class like this:
You would write:
(example from: http://projectlombok.org/features/GetterSetter.html)