DAVID MOLLITOR created FTPSERVER-442:
----------------------------------------
Summary: BaseUser Does Not Implement hashcode() or equals()
Key: FTPSERVER-442
URL: https://issues.apache.org/jira/browse/FTPSERVER-442
Project: FtpServer
Issue Type: Improvement
Components: Core
Affects Versions: 1.0.6
Reporter: DAVID MOLLITOR
Priority: Minor
The BaseUser class does not implement hashcode() or equals. In my
FileSystemFactory implementation, I show a different view to the same client
based on the number of concurrent logins for a single user. To perform this
task, I track the number of user logins in Map<User, Integer>. This does not
work though because User does not implement hashcode() or equals(). I
recommend... for BaseUser:
{code}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
String name = getName();
return (name == null) ? 0 : name.hashCode();
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
BaseUser other = (BaseUser) obj;
if (name == null) {
if (other.getName()!= null) {
return false;
}
} else if (!getName().equals(other.getName())) {
return false;
}
return true;
}
{code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira