![JAR search and dependency download from the Maven repository](/logo.png)
com.evasion.entity.content.Comment Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of API Show documentation
Show all versions of API Show documentation
API de l'application modulaire evasion-en-ligne
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.evasion.entity.content;
import com.evasion.entity.security.User;
import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.annotation.PostConstruct;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
/**
* Business Object representant un commentaire.
* @author sebastien
*/
@Entity
@Table(name = "comment")
public class Comment implements Serializable {
/***
* serialVersionUID.
*/
private static final long serialVersionUID = 1L;
/**
* Id technique.
*/
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
private User user;
/**
* Texte de la contribution.
*/
@Lob
@Column(nullable = false)
private String text;
/**
* Date d'enregistrement de la contribution.
*/
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Calendar dateEnregistrement;
/**
* Initialise la date de création du commentaire.
*/
@PostConstruct
private void initDateEnregistrement() {
if (dateEnregistrement == null) {
dateEnregistrement = new GregorianCalendar();
}
}
/**
* Getter de l'ID technique.
* @return ID technique.
*/
public Long getId() {
return id;
}
/**
* Setter de l'ID technique.
* @param id ID technique.
*/
public void setId(Long id) {
this.id = id;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
/**
* Getter de la date d'enregistrement de la contribution.
* @return renvoi la date.
*/
public Date getDateEnregistrement() {
initDateEnregistrement();
return dateEnregistrement.getTime();
}
/**
* Setter de la date d'enregistrement.
* Cette propriete n'est pas directement modifiable par l'utilisateur.
* La valeur est initialise dans le constructeur de l'objet.
* @param dateEnregistrement
*/
protected void setDateEnregistrement(Date dateEnregistrement) {
this.dateEnregistrement.setTime(dateEnregistrement);
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
/**
* {@inheritDoc }.
*/
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (!( obj instanceof Comment )) {
return false;
}
final Comment other = (Comment) obj;
return new EqualsBuilder().append(this.id, other.id).isEquals();
}
/**
* {@inheritDoc }.
*/
@Override
public int hashCode() {
return new HashCodeBuilder().append(id).toHashCode();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy