package ub.scp2.entities;

import java.util.HashSet;
import java.util.Set;

/**
 * Subject.java -this class is an entity binded to the subject table from the database
 * 
 *
 */
public class Subject implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6733356246301670895L;
	private Long subjectId;
	private String title;
	private Set<User> users = new HashSet<User>(0);
	private Set<Task> tasks = new HashSet<Task>(0);


	public Subject() {
	}

	public Subject(String title) {
		this.title = title;
	}

	public Long getSubjectId() {
		return this.subjectId;
	}

	public void setSubjectId(Long subjectId) {
		this.subjectId = subjectId;
	}

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Set<User> getUsers() {
		return users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}

	public Set<Task> getTasks() {
		return tasks;
	}

	public void setTasks(Set<Task> tasks) {
		this.tasks = tasks;
	}
	
    public boolean equals(Object other) {
        return other instanceof Subject && (subjectId != null) ? subjectId.equals(((Subject) other).subjectId) : (other == this);
    }

    public int hashCode() {
        return subjectId != null ? this.getClass().hashCode() + subjectId.hashCode() : super.hashCode();
    }

    public String toString() {
        return subjectId.toString();
    }


}
