package info.bukova.isspst.data;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**
 * @author Pepa Rokos
 */
@Entity
@Table(name = "SEASON")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Season extends BaseData {
	@Column(name = "DESCRIPTION")
	private String description;
	@Column(name = "VALID_FROM")
	private Date validFrom;
	@Column(name = "VALID_TO")
	private Date validTo;
	@Column(name = "ACTIVE")
	private boolean active;

	public String getDescription() {
		return description;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (!(o instanceof Season)) return false;

		Season season = (Season) o;

		if (getId() != season.getId()) return  false;
		if (active != season.active) return false;
		if (description != null ? !description.equals(season.description) : season.description != null) return false;
		if (validFrom != null ? !validFrom.equals(season.validFrom) : season.validFrom != null) return false;
		if (validTo != null ? !validTo.equals(season.validTo) : season.validTo != null) return false;

		return true;
	}

	@Override
	public int hashCode() {
		int result = description != null ? description.hashCode() : 0;
		result = 31 * result + (validFrom != null ? validFrom.hashCode() : 0);
		result = 31 * result + (validTo != null ? validTo.hashCode() : 0);
		result = 31 * result + (active ? 1 : 0);
		return result;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getValidFrom() {
		return validFrom;
	}

	public void setValidFrom(Date validFrom) {
		this.validFrom = validFrom;
	}

	public Date getValidTo() {
		return validTo;
	}

	public void setValidTo(Date validTo) {
		this.validTo = validTo;
	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}
}
