package org.yacos.core.users;

import java.io.Serializable;

import org.yacos.core.conferences.Conference;
import org.yacos.core.users.Role.RoleType;

public class RolePK implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * Public key, as described here : http://www.jpox.org/docs/1_2/primary_key.html
	 */
	public RoleType type;
	/**
	 * Public key, as described here : http://www.jpox.org/docs/1_2/primary_key.html
	 */
	public User user;
	/**
	 * Public key, as described here : http://www.jpox.org/docs/1_2/primary_key.html
	 */
	public Conference conference;

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof RolePK)) {
			return false;
		}
		RolePK otherPK = (RolePK) obj;
		return type.equals(otherPK.type)&&
				user.getLogin().equals(otherPK.user.getLogin())&&
				conference.getId() == otherPK.conference.getId();
	}
	
	@Override
	public int hashCode() {
		return type.hashCode() ^ user.hashCode() ^ conference.hashCode();
	}
	
}
