Home
Examples
Tutorials
Errata
/ch3/defaultValidate/RequestDataDefault.java
/ch3/defaultValidate/RequestDataDefault.java
package ch3.defaultValidate; public class RequestDataDefault { protected String hobby; protected String aversion; public void setHobby(String hobby) { this.hobby = hobby; } public String getHobby() { if (isValidHobby()) { return hobby; } return "No Hobby"; } public void setAversion(String aversion) { this.aversion = aversion; } public String getAversion() { if (isValidAversion()) { return aversion; } return "No Aversion"; } public boolean isValidHobby() { return hobby != null && !hobby.trim().equals(""); } public boolean isValidAversion() { return aversion != null && !aversion.trim().equals(""); } }
Contact the author