package fr.ekito.example.domain;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.joda.deser.LocalDateDeserializer;
import fr.ekito.example.domain.util.CustomLocalDateSerializer;
import org.joda.time.LocalDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* A Book.
*/
@Document(collection = "T_BOOK")
public class Book extends MultitenantEntity implements Serializable {
@Id
private String id;
@Field("title")
private String title;
@Field("description")
private String description;
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = CustomLocalDateSerializer.class)
@Field("publication_date")
private LocalDate publicationDate;
@Field("price")
private BigDecimal price;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public LocalDate getPublicationDate() {
return publicationDate;
}
public void setPublicationDate(LocalDate publicationDate) {
this.publicationDate = publicationDate;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Book book = (Book) o;
if (id != null ? !id.equals(book.id) : book.id != null) return false;
return true;
}
@Override
public int hashCode() {
return id != null ? id.hashCode() : 0;
}
@Override
public String toString() {
return "Book{" +
"id=" + id +
", title='" + title + "'" +
", description='" + description + "'" +
", publicationDate='" + publicationDate + "'" +
", price='" + price + "'" +
'}';
}
}