Class ProjectList

All Implemented Interfaces:
Saveable

public class ProjectList extends ModelList<Project>
Manages a list of Project objects, handling data persistence and retrieval. This class extends the generic ModelList to specialize in managing project data, likely loaded from and saved to a CSV file specified by the internal FILE_PATH. It provides methods to access the list instance and retrieve projects by their ID. Uses a static factory method getInstance() for convenient access.
  • Constructor Details

    • ProjectList

      public ProjectList()
      Constructs a ProjectList instance. Calls the superclass constructor using the default FILE_PATH and passing the Project.class type for CSV data mapping. Typically accessed via the static getInstance() method.
  • Method Details

    • getInstance

      public static ProjectList getInstance()
      Provides a static factory method to get an instance of ProjectList. This method creates a new instance using the default FILE_PATH. Note: This implementation creates a new instance on each call, potentially reloading data. Consider implementing a true Singleton pattern if a single shared instance is desired.
      Returns:
      A new instance of ProjectList initialized with the default file path.
    • getFilePath

      public String getFilePath()
      Description copied from class: ModelList
      Gets the specific file path used by the concrete subclass for data persistence. Subclasses must implement this method to define where their data is stored.
      Specified by:
      getFilePath in class ModelList<Project>
      Returns:
      The file path string for loading and saving data.
    • getByID

      public Project getByID(String ID)
      Retrieves a Project from the list based on its unique project ID. Iterates through the list maintained by the superclass (ModelList.getAll()) and returns the first project matching the provided ID.
      Specified by:
      getByID in class ModelList<Project>
      Parameters:
      ID - The project ID (e.g., "PRJ001") of the project to find.
      Returns:
      The Project object if found, otherwise null.