Java tutorial
/** * Timer Review - a personal time management tool * * * Copyright (C) 2012 - 2014 Parentini Massimiliano * Project home page: http://www.timer-review.net * * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. */ package zxmax.tools.timerreview.domain; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.validation.constraints.Size; import org.hibernate.annotations.Type; import org.joda.time.LocalDateTime; @Entity public class Tomato implements Serializable { /** * */ private static final long serialVersionUID = 3639516598781830323L; @Column(nullable = true, length = 80) @Size(min = 0, max = 80) private String title; @Column(nullable = false, length = 500) @Size(min = 0, max = 500) private String focusOn; @Id @Column(name = "ID", unique = true, nullable = false, scale = 0) @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Column(nullable = false) // @Type(type="org.joda.time.contrib.hibernate.PersistentDateTime") @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime") private LocalDateTime startTime; @Column private Integer duration; public Tomato() { super(); } public Tomato(String focusOn) { this.focusOn = focusOn; startTime = new LocalDateTime(); } public String getFocusOn() { return focusOn; } public Long getId() { return id; } public LocalDateTime getStartTime() { return startTime; } public void setFocusOn(String focusOn) { this.focusOn = focusOn; } public void setId(Long id) { this.id = id; } public void setStartTime(LocalDateTime startTime) { this.startTime = startTime; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public int getDuration() { return duration; } public void setDuration(int duration) { this.duration = duration; } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Tomato [title="); builder.append(title); builder.append(", id="); builder.append(id); builder.append(", focusOn="); builder.append(focusOn); builder.append(", startTime="); builder.append(startTime); builder.append("]"); return builder.toString(); } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((duration == null) ? 0 : duration.hashCode()); result = prime * result + ((focusOn == null) ? 0 : focusOn.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((startTime == null) ? 0 : startTime.hashCode()); result = prime * result + ((title == null) ? 0 : title.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Tomato other = (Tomato) obj; if (duration == null) { if (other.duration != null) { return false; } } else if (!duration.equals(other.duration)) { return false; } if (focusOn == null) { if (other.focusOn != null) { return false; } } else if (!focusOn.equals(other.focusOn)) { return false; } if (id == null) { if (other.id != null) { return false; } } else if (!id.equals(other.id)) { return false; } if (startTime == null) { if (other.startTime != null) { return false; } } else if (!startTime.equals(other.startTime)) { return false; } if (title == null) { if (other.title != null) { return false; } } else if (!title.equals(other.title)) { return false; } return true; } }