Is it a good practice to have trim in setter?
- by zibi
I'm doing a code review and I noticed such a code:
@Entity
@Table(name = "SOME_TABLE")
public class SomeReportClass {
@Column(name = "REPORT_NUMBER", length = 6, nullable = false)
private String reportNumber;
.....
public String getReportNumber() {
return reportNumber;
}
public void setReportNumber(String reportNumber) {
this.reportNumber = StringUtils.trimToNull(reportNumber);
}
}
Every time I see trimming inside of a setter I feel that its not the clearest solution - what is the general practice with that issue?