Class ProjectList
- All Implemented Interfaces:
Saveable
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves aProjectfrom the list based on its unique project ID.Gets the specific file path used by the concrete subclass for data persistence.static ProjectListProvides a static factory method to get an instance of ProjectList.
-
Constructor Details
-
ProjectList
public ProjectList()Constructs a ProjectList instance. Calls the superclass constructor using the defaultFILE_PATHand passing theProject.classtype for CSV data mapping. Typically accessed via the staticgetInstance()method.
-
-
Method Details
-
getInstance
Provides a static factory method to get an instance of ProjectList. This method creates a new instance using the defaultFILE_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
ProjectListinitialized with the default file path.
-
getFilePath
Description copied from class:ModelListGets 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:
getFilePathin classModelList<Project>- Returns:
- The file path string for loading and saving data.
-
getByID
Retrieves aProjectfrom 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.
-