From 70381b3187aab32d4facb74d327ac79bbc2669ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Oliva?= Date: Thu, 25 May 2023 13:07:01 -0600 Subject: Added ToDos class. Class for saving all single to dos. --- src/main/java/com/encora/ToDos.java | 124 ++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 src/main/java/com/encora/ToDos.java (limited to 'src/main/java/com') diff --git a/src/main/java/com/encora/ToDos.java b/src/main/java/com/encora/ToDos.java new file mode 100644 index 0000000..9fc69e4 --- /dev/null +++ b/src/main/java/com/encora/ToDos.java @@ -0,0 +1,124 @@ +package com.encora; + +import jakarta.persistence.*; + +import java.util.Date; +import java.util.Objects; + +enum Priority { + LOW, MEDIUM, HIGH; +} + +@Entity +public class ToDos { + @Id + @SequenceGenerator( + name = "to_do_id", + sequenceName = "to_do_id", + allocationSize = 1 + ) + @GeneratedValue( + strategy = GenerationType.SEQUENCE, + generator = "to_do_id" + ) + private Integer id; + private String text; + private Date dueDate; + private boolean done; + private Date doneDate; + private Priority priority; + private Date creationDate; + + public ToDos(String text, Date dueDate, Priority priority) { + this.text = text; + this.dueDate = dueDate; + this.priority = priority; + this.creationDate = new Date(); + } + + public ToDos() { + this.creationDate = new Date(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Date getDueDate() { + return dueDate; + } + + public void setDueDate(Date dueDate) { + this.dueDate = dueDate; + } + + public boolean isDone() { + return done; + } + + public void setDone(boolean done) { + this.done = done; + } + + public Date getDoneDate() { + return doneDate; + } + + public void setDoneDate(Date doneDate) { + this.doneDate = doneDate; + } + + public Priority getPriority() { + return priority; + } + + public void setPriority(Priority priority) { + this.priority = priority; + } + + public Date getCreationDate() { + return creationDate; + } + + public void setCreationDate(Date creationDate) { + this.creationDate = creationDate; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ToDos toDos = (ToDos) o; + return done == toDos.done && Objects.equals(id, toDos.id) && Objects.equals(text, toDos.text) && Objects.equals(dueDate, toDos.dueDate) && Objects.equals(doneDate, toDos.doneDate) && priority == toDos.priority && Objects.equals(creationDate, toDos.creationDate); + } + + @Override + public int hashCode() { + return Objects.hash(id, text, dueDate, done, doneDate, priority, creationDate); + } + + @Override + public String toString() { + return "ToDos{" + + "id=" + id + + ", text='" + text + '\'' + + ", dueDate=" + dueDate + + ", done=" + done + + ", doneDate=" + doneDate + + ", priority=" + priority + + ", creationDate=" + creationDate + + '}'; + } +} -- cgit v1.2.3