aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/encora/ToDos.java
blob: 0e4b51251cd8d7a5eb4b9a57d5aaa2851bbf7b25 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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 +
                '}';
    }
}