0% found this document useful (0 votes)
5 views2 pages

Todo Database

The document defines a Todo class in a Spring Boot application, which represents a task with attributes such as id, username, description, target date, and completion status. It includes validation for the description length and methods for toggling completion status and accessing/modifying the attributes. The class is annotated for persistence with JPA and includes a constructor and a toString method for easy representation.

Uploaded by

David Pavlovski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Todo Database

The document defines a Todo class in a Spring Boot application, which represents a task with attributes such as id, username, description, target date, and completion status. It includes validation for the description length and methods for toggling completion status and accessing/modifying the attributes. The class is annotated for persistence with JPA and includes a constructor and a toString method for easy representation.

Uploaded by

David Pavlovski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

package com.davidpavlovski.springboot.todoApp.

todo;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Size;
import org.springframework.context.annotation.Primary;

import java.time.LocalDate;

@Table
@Entity
public class Todo {
@Id
@GeneratedValue
private int id;
private String username;
@Size(min = 5, message = "Description must be at least 5 characters")
private String description;
private LocalDate targetDate;
private boolean completed;

public Todo() {
super();
}

public Todo(String username, String description, LocalDate targetDate, boolean


completed) {
this.username = username;
this.description = description;
this.targetDate = targetDate;
this.completed = completed;
}

@Override
public String toString() {
return "Todo{" +
"id=" + id +
", username='" + username + '\'' +
", description='" + description + '\'' +
", targetDate=" + targetDate +
", completed=" + completed +
'}';
}

public void toggleComplete() {


completed = !completed;
}

public int getId() {


return id;
}

public void setId(int id) {


this.id = id;
}

public String getUsername() {


return username;
}

public void setUsername(String username) {


this.username = username;
}

public String getDescription() {


return description;
}

public void setDescription(String description) {


this.description = description;
}

public LocalDate getTargetDate() {


return targetDate;
}

public void setTargetDate(LocalDate targetDate) {


this.targetDate = targetDate;
}

public boolean isCompleted() {


return completed;
}

public void setCompleted(boolean completed) {


this.completed = completed;
}

You might also like