package devopsdistilled.operp.server.data.entity.items;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;

import devopsdistilled.operp.server.data.entity.Entiti;

@Entity
public class Category extends Entiti implements Serializable {

	private static final long serialVersionUID = -3809686715120885998L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long categoryId;

	@Column(unique = true)
	private String categoryName;

	@ManyToMany(mappedBy = "categories")
	private List<Product> products;

	public Long getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(Long categoryId) {
		this.categoryId = categoryId;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	public List<Product> getProducts() {
		return products;
	}

	public void setProducts(List<Product> products) {
		this.products = products;
	}

	@Override
	public String toString() {
		return getCategoryName();
	}

}

@@ -443,16 +443,40 @@
 alizable
+,%0A%09%09Comparable%3CCategory%3E
  %7B%0A%0A%09pri
@@ -1256,10 +1256,200 @@
 ();%0A%09%7D%0A%0A
+%09@Override%0A%09public int compareTo(Category anotherCategory) %7B%0A%0A%09%09return (this.categoryId %3C anotherCategory.categoryId) ? -1%0A%09%09%09%09: (this.categoryId %3E anotherCategory.categoryId) ? 1 : 0;%0A%0A%09%7D%0A%0A
 %7D%0A

Implement Comparable Interface