package org.jhipster.health.domain; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.jhipster.health.domain.enumeration.Units; import org.springframework.data.elasticsearch.annotations.Document; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; import javax.validation.constraints.Max; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.Objects; /** * A Preferences. */ @Entity @Table(name = "preferences") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) @Document(indexName = "preferences") public class Preferences implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @NotNull @Min(value = 10) @Max(value = 21) @Column(name = "weekly_goal", nullable = false) private Integer weeklyGoal; @NotNull @Enumerated(EnumType.STRING) @Column(name = "weight_units", nullable = false) private Units weightUnits; @OneToOne @JoinColumn(unique = true) private User user; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Integer getWeeklyGoal() { return weeklyGoal; } public Preferences weeklyGoal(Integer weeklyGoal) { this.weeklyGoal = weeklyGoal; return this; } public void setWeeklyGoal(Integer weeklyGoal) { this.weeklyGoal = weeklyGoal; } public Units getWeightUnits() { return weightUnits; } public Preferences weightUnits(Units weightUnits) { this.weightUnits = weightUnits; return this; } public void setWeightUnits(Units weightUnits) { this.weightUnits = weightUnits; } public User getUser() { return user; } public Preferences user(User user) { this.user = user; return this; } public void setUser(User user) { this.user = user; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Preferences preferences = (Preferences) o; if (preferences.id == null || id == null) { return false; } return Objects.equals(id, preferences.id); } @Override public int hashCode() { return Objects.hashCode(id); } @Override public String toString() { return "Preferences{" + "id=" + id + ", weeklyGoal='" + weeklyGoal + "'" + ", weightUnits='" + weightUnits + "'" + '}'; } }