Improved detection of invalid parameters in constructors.

This commit is contained in:
Ben Alex 2004-03-28 12:14:11 +00:00
parent 3179f5f1e7
commit 489c941101

View File

@ -46,17 +46,24 @@ public class User {
* @param authorities the authorities that should be granted to the caller * @param authorities the authorities that should be granted to the caller
* if they presented the correct username and password and the user * if they presented the correct username and password and the user
* is enabled * is enabled
*
* @throws IllegalArgumentException if a <code>null</code> value was passed
*/ */
public User(String username, String password, boolean enabled, public User(String username, String password, boolean enabled,
GrantedAuthority[] authorities) { GrantedAuthority[] authorities) throws IllegalArgumentException {
if ((username == null) || (password == null) || (authorities == null)) {
throw new IllegalArgumentException(
"Cannot pass null values to constructor");
}
this.username = username; this.username = username;
this.password = password; this.password = password;
this.enabled = enabled; this.enabled = enabled;
this.authorities = authorities; this.authorities = authorities;
} }
private User() { protected User() {
super(); throw new IllegalArgumentException("Cannot use default constructor");
} }
//~ Methods ================================================================ //~ Methods ================================================================