Comment.java
package com.tradecloud.domain.comment;
import com.tradecloud.common.base.PersistenceBase;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.springframework.stereotype.Component;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@Entity
@Component(value = "comment")
@Table(name = "comment", uniqueConstraints = {@UniqueConstraint(columnNames = {"commentType", "commentText"})})
@NamedQueries({@NamedQuery(name = "comment.byType", query = "from Comment where commentType = :commentType")})
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "Comment")
public class Comment extends PersistenceBase {
private static final long serialVersionUID = -1823347412359419439L;
/**
* The comment type.
*/
@NotNull(message = "Comment type is required")
@Enumerated(value = EnumType.STRING)
private CommentType commentType;
/**
* The comment text.
*/
@NotNull(message = "Comment text is required")
@Size(max = 255, message = "comment text cannot exceed 255 characters")
private String commentText;
public Comment(String text, CommentType type) {
this.commentText = text;
this.commentType = type;
}
public Comment() {
}
public String getCommentText() {
return commentText;
}
public void setCommentText(String commentText) {
this.commentText = commentText;
}
public CommentType getCommentType() {
return commentType;
}
public void setCommentType(CommentType commentType) {
this.commentType = commentType;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Comment other = (Comment) obj;
return new EqualsBuilder().append(commentType, other.getCommentType()).append(commentText, other.getCommentText()).isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder().append(commentType).append(commentText).toHashCode();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("id=");
sb.append(getId()).append("commentText=").append(commentText).append(",commentType=").append(commentType);
return sb.toString();
}
}