package eu.dnetlib.goldoa.domain;

import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * Created by antleb on 3/8/15.
 */
public class PersonRole implements IsSerializable {

	private Person person;
	private Role role;
	private boolean approved = false;

	public PersonRole() {
	}

	public PersonRole(Person person, Role role, boolean approved) {
		this.person = person;
		this.role = role;
		this.approved = approved;
	}

	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public boolean isApproved() {
		return approved;
	}

	public void setApproved(boolean approved) {
		this.approved = approved;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;

		PersonRole that = (PersonRole) o;

		if (approved != that.approved) return false;
		if (person != null ? !person.equals(that.person) : that.person != null) return false;
		if (role != null ? !role.equals(that.role) : that.role != null) return false;

		return true;
	}

	@Override
	public int hashCode() {
		int result = person != null ? person.hashCode() : 0;
		result = 31 * result + (role != null ? role.hashCode() : 0);
		result = 31 * result + (approved ? 1 : 0);
		return result;
	}
}
