package src.hibernatebb.discussion;

import java.util.List;
import java.util.ArrayList;
import java.util.Date;

/**
 * A topic in the bulletin board. <code>Topic</code>'s have <code>Post</code>s.
 * A <code>Topic</code> is comprised of a id (subject) and a list of <code>Post</code>s. 
 * 
 * The design of this class was heavily based on the example code in Better, Faster, Lighter Java
 *  by authors Bruce Tate and Justin Gehtland.
 * 
 * @author Peter Deschere
 * @version 1.0
 * @see <a>http://www.hibernate.org</a>
 * @see src.hibernatebb.discussion.User
 * @see src.hibernatebb.discussion.Post
 */
public class Topic {
	
	String id = "Unnamed Topic";
	List posts = new ArrayList();
	Date timestamp = new Date();
	Date modified = new Date();
	
	public Topic(String topicID) {
		id = topicID;
	}
	
	public Topic(Topic t) {
		this.id = new String(t.getID());
		this.posts = new ArrayList<ArrayList>(t.getPosts());
		this.timestamp = t.getTimestamp();
		this.modified = t.getModified();
	}
	
	public Topic() {
		
	}
	
	public String getID() {
		return id;
	}
	
	public void setID(String topic) {
		id = topic;
	}
	
	public List getPosts() {
		return posts;
	}
	
	public void setPosts(List p) {
		posts = p;
	}
	
	public Date getTimestamp() {
		return timestamp;
	}
	
	public void setTimestamp(Date t) {
		timestamp = t;
	}
	
	public Date getModified() {
		return timestamp;
	}
	
	public void setModified(Date t) {
		timestamp = t;
	}

	public void addPost(Post p){
		posts.add(p);
	}
	
}