package cz.coffei.foodo.data.entities;
import org.hibernate.validator.constraints.NotEmpty;
import javax.persistence.*;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
/**
* Created by jtrantin on 25.7.15.
*/
@Entity
public class Ingredient {
@Id
@GeneratedValue
private Long id;
@NotNull
@NotEmpty
private String name;
private String description;
@Min(value = 0)
private Integer price;
@ManyToOne(fetch = FetchType.EAGER, optional = false)
private IngredientGroup group;
public Integer getPrice() {
return price;
}
public void setPrice(Integer price) {
this.price = price;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public IngredientGroup getGroup() {
return group;
}
public void setGroup(IngredientGroup group) {
this.group = group;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Ingredient that = (Ingredient) o;
if (id != null ? !id.equals(that.id) : that.id != null) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
if (description != null ? !description.equals(that.description) : that.description != null) return false;
return !(price != null ? !price.equals(that.price) : that.price != null);
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (description != null ? description.hashCode() : 0);
result = 31 * result + (price != null ? price.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "Ingredient{" +
"id=" + id +
", name='" + name + '\'' +
", description='" + description + '\'' +
", price=" + price +
'}';
}
}