/*
* Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Florent Guillaume
*/
package org.eclipse.ecr.core.storage;
/**
* Simple username + password.
*
* @author Florent Guillaume
*/
public final class Credentials {
private final String username;
private final String password;
public Credentials(String username, String password) {
this.username = username;
this.password = password;
}
public String getUserName() {
return username;
}
public String getPassword() {
return password;
}
@Override
public int hashCode() {
int result = 31 + ((username == null) ? 0 : username.hashCode());
return 31 * result + ((password == null) ? 0 : password.hashCode());
}
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}
if (other instanceof Credentials) {
return equals((Credentials) other);
}
return false;
}
private boolean equals(Credentials other) {
if (username == null) {
if (other.username != null) {
return false;
}
} else if (!username.equals(other.username)) {
return false;
}
if (password == null) {
if (other.password != null) {
return false;
}
} else if (!password.equals(other.password)) {
return false;
}
return true;
}
}