org.jarbframework.sample.Post Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jarb-sample Show documentation
Show all versions of jarb-sample Show documentation
Sample application that demonstrates all modules.
package org.jarbframework.sample;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotEmpty;
import org.jarbframework.constraint.validation.DatabaseConstrained;
@Entity
@Table(name = "posts")
@DatabaseConstrained
public class Post {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Email
private String author;
@NotEmpty
private String title;
private String message;
@Column(name = "posted_on")
private Date postedOn = new Date();
public Long getId() {
return id;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Date getPostedOn() {
return postedOn;
}
/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
boolean equals = false;
if (obj instanceof Post) {
equals = title.equals(((Post) obj).title);
}
return equals;
}
/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return title.hashCode();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy