Listify/Lambdas/Lists/SearchHistory/src/SearchHistory.java
NMerz 3afaad89ea Use plain table search history
This is easier, clearer, faster for inters, and ultimately not really much less space efficient than trying to store this in a serialized nor unreasonably slow for retrievals.

Food for thought: Would this might be well-suited to a nosql database?
2020-11-14 12:05:50 -05:00

44 lines
1021 B
Java

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
public class SearchHistory implements Serializable {
ArrayList<String> searches;
public SearchHistory(ArrayList<String> searches) {
this.searches = searches;
}
public SearchHistory() {
this.searches = new ArrayList<>();
}
public SearchHistory(ResultSet row) throws SQLException {
this.searches = new ArrayList<>();
row.beforeFirst();
while (row.next()) {
this.searches.add(row.getString("search"));
}
}
public ArrayList<String> getSearches() {
return searches;
}
public void setSearches(ArrayList<String> searches) {
this.searches = searches;
}
public void addSearch(String newSearch) {
searches.add(newSearch);
}
@Override
public String toString() {
return "SearchHistory{" +
"searches=" + searches +
'}';
}
}