/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.portletbridge.richfaces.simple;
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
/**
* @author <a href="http://community.jboss.org/people/kenfinni">Ken Finnigan</a>
*/
public class User implements Serializable {
private static final long serialVersionUID = 7530955664685217593L;
@NotNull
@Size(min = 3, max = 20)
private String firstName;
@NotNull
@Size(min = 3, max = 40)
private String lastName;
@NotNull
@Pattern(regexp = "^[\\w\\-]([\\.\\w])+[\\w]+@([\\w\\-]+\\.)+[a-zA-Z]{2,4}$", message = "Bad email")
private String email;
@NotNull
private UserType userType;
public User() {
}
public User(String first, String last, String email, UserType type) {
firstName = first;
lastName = last;
this.email = email;
userType = type;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public UserType getUserType() {
return userType;
}
public void setUserType(UserType userType) {
this.userType = userType;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (null == obj) {
return false;
}
if (!(obj instanceof User)) {
return false;
}
User other = (User) obj;
if (null == firstName) {
if (null != other.firstName) {
return false;
}
} else if (!firstName.equals(other.firstName)) {
return false;
}
if (null == lastName) {
if (null != other.lastName) {
return false;
}
} else if (!lastName.equals(other.lastName)) {
return false;
}
if (null == email) {
if (null != other.email) {
return false;
}
} else if (!email.equals(other.email)) {
return false;
}
if (null == userType) {
if (null != other.userType) {
return false;
}
} else if (!userType.equals(other.userType)) {
return false;
}
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = (prime * result) + (null == firstName ? 0 : firstName.hashCode())
+ (null == lastName ? 0 : lastName.hashCode()) + (null == email ? 0 : email.hashCode());
return result;
}
}