package se.chalmers.watchme.model;

import java.io.Serializable;

/**
 * A class that represents a Tag.
 * 
 * @author mattiashenriksson
 * @author lisastenberg
 */

public class Tag implements Serializable {

	private String name;
	private String slug;
	private long id;
	
	/**
	 * Creates a Tag and generates a slug after the given name.
	 * @param name The name of the Tag.
	 */
	public Tag(String name) {
		this.name = name;
		this.slug = generateSlug(name);
	}
	
	/**
	 * @return the id of the Tag.
	 */
	public long getId() {
		return this.id;
	}
	
	/**
	 * Sets the id.
	 * @param id the id you want to set.
	 */
	public void setId(long id) {
		this.id = id;
	}
	
	/**
	 * @return The name of the Tag.
	 */
	public String getName() {
		return this.name;
	}
	
	/**
	 * @return The slug.
	 */
	public String getSlug() {
		return this.slug;
	}
	
	/**
	 * Generates a slug of a given string.
	 * @param s The string.
	 * @return The slug.
	 */
	public static String generateSlug(String s) {
		return s.toLowerCase();
	}
	
	@Override
	public String toString() {
		return this.name;
	}
	
	@Override
	public boolean equals(Object o) {
		if(this == o) {
			return true;
		} else if(o == null || this.getClass() != o.getClass()) {
			return false;
		} else {
			Tag tmp = (Tag)o;
			return this.getSlug().equals(tmp.getSlug());
		}
	}
}

@@ -1326,10 +1326,82 @@
 %0A%09%09%7D%0A%09%7D%0A
+%09%0A%09@Override%0A%09public int hashCode() %7B%0A%09%09return this.slug.hashCode();%0A%09%7D%0A
 %7D%0A

Implement hashCode in Tag model