summaryrefslogtreecommitdiff
path: root/src/main/java/design/model/course_search
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2025-10-30 08:30:26 -0400
committersowgro <tpoke.ferrari@gmail.com>2025-10-30 08:30:26 -0400
commit58d32481c71e5aee7c89dab3afc3b1e3bdb8c074 (patch)
tree01ed290f8b3c524fc033d22fc25c9a6193c8cf10 /src/main/java/design/model/course_search
parentf793ece34e825f9e6e6d84146d0dfc533ae6816b (diff)
downloaddesignproject-design-6-58d32481c71e5aee7c89dab3afc3b1e3bdb8c074.tar.gz
designproject-design-6-58d32481c71e5aee7c89dab3afc3b1e3bdb8c074.tar.bz2
designproject-design-6-58d32481c71e5aee7c89dab3afc3b1e3bdb8c074.zip
Remove singleton from course search subsystemsingleton-daos
Diffstat (limited to 'src/main/java/design/model/course_search')
-rw-r--r--src/main/java/design/model/course_search/CurrentSearchQuery.java24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/main/java/design/model/course_search/CurrentSearchQuery.java b/src/main/java/design/model/course_search/CurrentSearchQuery.java
index b302261..b7f0686 100644
--- a/src/main/java/design/model/course_search/CurrentSearchQuery.java
+++ b/src/main/java/design/model/course_search/CurrentSearchQuery.java
@@ -10,19 +10,11 @@ import java.util.stream.Collectors;
* Represents the state of our current search.
*/
public class CurrentSearchQuery {
- private static CurrentSearchQuery INSTANCE;
-
- public static CurrentSearchQuery instance() {
- if (INSTANCE == null) {
- INSTANCE = new CurrentSearchQuery();
- }
- return INSTANCE;
- }
// initialize our search with the master db data
MasterDatabase db = MasterDatabase.instance();
private CourseList query = db.getCourseList();
- private final List<CourseSorter> filters = new ArrayList<CourseSorter>();
+ private final List<CourseSorter> filters = new ArrayList<>();
// reset the query
public void reset() {
@@ -41,22 +33,22 @@ public class CurrentSearchQuery {
// print out the filters we're currently using and the order
public String printFilters() {
- String filterResult = "";
+ StringBuilder filterResult = new StringBuilder();
// no filters? let the user know.
- if (filters.size() == 0) {
+ if (filters.isEmpty()) {
return "nothing";
}
for (CourseSorter f : filters) {
- filterResult += f.toString() + " --> ";
+ filterResult.append(f.toString()).append(" --> ");
}
// remove last arrow and add padding
- filterResult = filterResult.substring(0, filterResult.length() - 5);
- filterResult += "\n";
+ filterResult = new StringBuilder(filterResult.substring(0, filterResult.length() - 5));
+ filterResult.append("\n");
- return filterResult;
+ return filterResult.toString();
}
// get all the filters
@@ -135,7 +127,7 @@ public class CurrentSearchQuery {
// make a CourseList group, a sublist of a group, and filter it.
private ICourse makeGroup(List<ICourse> group, List<CourseSorter> filters, int level) {
// base case, group only has one course in it (already sorted)
- if (group.size() == 1) return group.get(0);
+ if (group.size() == 1) return group.getFirst();
// group has more than 1 course in it, it needs to be sorted more if possible.
CourseList subList = new CourseList();