diff options
Diffstat (limited to '')
-rw-r--r-- | pom.xml | 5 | ||||
-rw-r--r-- | src/main/java/com/encora/ToDos.java | 124 |
2 files changed, 129 insertions, 0 deletions
@@ -18,6 +18,11 @@ </properties> <dependencies> <dependency> + <groupId>jakarta.persistence</groupId> + <artifactId>jakarta.persistence-api</artifactId> + </dependency> + + <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> 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 + + '}'; + } +} |