package org.jhipster.health.domain;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.ZonedDateTime;
import java.util.Objects;
/**
* A Weight.
*/
@Entity
@Table(name = "weight")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "weight")
public class Weight implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@NotNull
@Column(name = "timestamp", nullable = false)
private ZonedDateTime timestamp;
@NotNull
@Column(name = "weight", nullable = false)
private Double weight;
@ManyToOne
private User user;
public Weight() {}
public Weight(ZonedDateTime timestamp, Double weight, User user) {
this.timestamp = timestamp;
this.weight = weight;
this.user = user;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public ZonedDateTime getTimestamp() {
return timestamp;
}
public Weight timestamp(ZonedDateTime timestamp) {
this.timestamp = timestamp;
return this;
}
public void setTimestamp(ZonedDateTime timestamp) {
this.timestamp = timestamp;
}
public Double getWeight() {
return weight;
}
public Weight weight(Double weight) {
this.weight = weight;
return this;
}
public void setWeight(Double weight) {
this.weight = weight;
}
public User getUser() {
return user;
}
public Weight 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;
}
Weight weight = (Weight) o;
if(weight.id == null || id == null) {
return false;
}
return Objects.equals(id, weight.id);
}
@Override
public int hashCode() {
return Objects.hashCode(id);
}
@Override
public String toString() {
return "Weight{" +
"id=" + id +
", timestamp='" + timestamp + "'" +
", weight='" + weight + "'" +
'}';
}
}