Sort members in the Java class in Spring STS

0Shares

In the post Generating Getters/Setters in Spring STS we have seen how to generate the Setters and Getters for private fields in the class. But the code looks cluttered and not sorted in a proper order. So, if you want to sort the members, again you do not need to do that by hand. Spring STS or any eclipse based tools will provide the option to sort the members.

Sort members in STS

Figure 1: Sort Members… option in STS

And now after sorting your code will be seen as below:

package com.bankaccount.model;

public class AccountHolder {

	private String accountHolderFirstName;

	private String accountHolderLastName;

	private String accountHolderMiddleName;

	public String getAccountHolderFirstName() {
		return accountHolderFirstName;
	}

	public String getAccountHolderLastName() {
		return accountHolderLastName;
	}

	public String getAccountHolderMiddleName() {
		return accountHolderMiddleName;
	}

	public void setAccountHolderFirstName(String accountHolderFirstName) {
		this.accountHolderFirstName = accountHolderFirstName;
	}

	public void setAccountHolderLastName(String accountHolderLastName) {
		this.accountHolderLastName = accountHolderLastName;
	}

	public void setAccountHolderMiddleName(String accountHolderMiddleName) {
		this.accountHolderMiddleName = accountHolderMiddleName;
	}
}

Figure 2: After sorting members

0Shares