Create Task Enums
Let's start coding our app's domain classes.
But we can't jump right to coding the Task class. First, we need to create a
couple of enums.
Create the Task Status Enum
When a user creates a new task we say it's open.
When a user performs the task we say it's complete.
Let's create an enum to capture this.
To keep things organised we'll create a dedicated package for our domain classes and a nested package for our entities.
This separates the classes we use to interact with the database from classes that don't.
Let's create the package com.devtiro.task.domain.entity for the classes we
use to interact with the database.
We'll create the TaskStatus enum in this package:
/** Models the status of a Task; either open or complete. */
public enum TaskStatus {
/** The task is open and is yet to be completed. */
OPEN,
/** The task has been completed. */
COMPLETE
}Create the Task Priority Enum
Tasks also have a priority, which can be high, medium, and low.
Let's model this with a new TaskPriority enum, creating it in the same
package:
/** Models the priority of a task, how important is it? */
public enum TaskPriority {
/** The highest priority, the most important to complete. */
HIGH,
/** The default priority, a task of average importance. */
MEDIUM,
/** The lowest priority, the least important to complete. */
LOW
}Now that we've created the TaskStatus and TaskPriority enums, we can
create the Task class.
Summary
- Created the
TaskStatusenum to model task status. - Created the
TaskPriorityenum to model task priority.