bstlboard-back/src/main/java/de/bstly/board/model/Comment.java

180 lines
2.9 KiB
Java

/**
*
*/
package de.bstly.board.model;
import java.time.Instant;
import java.util.Map;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import com.google.common.collect.Maps;
/**
* The Class Comment.
*/
@Entity
@Table(name = "comments")
@EntityListeners({ AuditingEntityListener.class })
public class Comment {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "author", nullable = false)
private String author;
@Column(name = "created", nullable = false)
private Instant created;
@Column(name = "target", nullable = false)
private Long target;
@Column(name = "parent", nullable = true)
private Long parent;
@Lob
@Column(name = "text", nullable = false)
private String text;
@Transient
private Map<String, Object> metadata;
/**
* Gets the id.
*
* @return the id
*/
public Long getId() {
return id;
}
/**
* Sets the id.
*
* @param id the new id
*/
public void setId(Long id) {
this.id = id;
}
/**
* Gets the author.
*
* @return the author
*/
public String getAuthor() {
return author;
}
/**
* Sets the author.
*
* @param author the new author
*/
public void setAuthor(String author) {
this.author = author;
}
/**
* Gets the created.
*
* @return the created
*/
public Instant getCreated() {
return created;
}
/**
* Sets the created.
*
* @param created the new created
*/
public void setCreated(Instant created) {
this.created = created;
}
/**
* Gets the target.
*
* @return the target
*/
public Long getTarget() {
return target;
}
/**
* Sets the target.
*
* @param target the new target
*/
public void setTarget(Long target) {
this.target = target;
}
/**
* Gets the parent.
*
* @return the parent
*/
public Long getParent() {
return parent;
}
/**
* Sets the parent.
*
* @param parent the new parent
*/
public void setParent(Long parent) {
this.parent = parent;
}
/**
* Gets the text.
*
* @return the text
*/
public String getText() {
return text;
}
/**
* Sets the text.
*
* @param text the new text
*/
public void setText(String text) {
this.text = text;
}
/**
* Gets the metadata.
*
* @return the metadata
*/
public Map<String, Object> getMetadata() {
if (metadata == null) {
metadata = Maps.newHashMap();
}
return metadata;
}
/**
* Sets the metadata.
*
* @param metadata the metadata
*/
public void setMetadata(Map<String, Object> metadata) {
this.metadata = metadata;
}
}