summaryrefslogtreecommitdiff
path: root/src/main/java/sevenUnitsGUI/SearchBoxList.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/sevenUnitsGUI/SearchBoxList.java')
-rw-r--r--src/main/java/sevenUnitsGUI/SearchBoxList.java47
1 files changed, 23 insertions, 24 deletions
diff --git a/src/main/java/sevenUnitsGUI/SearchBoxList.java b/src/main/java/sevenUnitsGUI/SearchBoxList.java
index 43a57ce..bddce04 100644
--- a/src/main/java/sevenUnitsGUI/SearchBoxList.java
+++ b/src/main/java/sevenUnitsGUI/SearchBoxList.java
@@ -49,7 +49,7 @@ final class SearchBoxList<E> extends JPanel {
/**
* The text to place in an empty search box.
- *
+ *
* @since 2019-04-13
* @since v0.2.0
*/
@@ -57,7 +57,7 @@ final class SearchBoxList<E> extends JPanel {
/**
* The color to use for an empty foreground.
- *
+ *
* @since 2019-04-13
* @since v0.2.0
*/
@@ -82,7 +82,7 @@ final class SearchBoxList<E> extends JPanel {
/**
* Creates an empty SearchBoxList
- *
+ *
* @since 2022-02-19
* @since v0.4.0
*/
@@ -92,7 +92,7 @@ final class SearchBoxList<E> extends JPanel {
/**
* Creates the {@code SearchBoxList}.
- *
+ *
* @param itemsToFilter items to put in the list
* @since 2019-04-14
* @since v0.2.0
@@ -103,12 +103,12 @@ final class SearchBoxList<E> extends JPanel {
/**
* Creates the {@code SearchBoxList}.
- *
+ *
* @param itemsToFilter items to put in the list
* @param defaultOrdering default ordering of items after filtration
* (null=Comparable)
* @param caseSensitive whether or not the filtration is case-sensitive
- *
+ *
* @since 2019-04-13
* @since v0.2.0
*/
@@ -149,7 +149,7 @@ final class SearchBoxList<E> extends JPanel {
/**
* Adds an additional filter for searching.
- *
+ *
* @param filter filter to add.
* @since 2019-04-13
* @since v0.2.0
@@ -160,7 +160,7 @@ final class SearchBoxList<E> extends JPanel {
/**
* Resets the search filter.
- *
+ *
* @since 2019-04-13
* @since v0.2.0
*/
@@ -183,7 +183,7 @@ final class SearchBoxList<E> extends JPanel {
* @since 2019-04-14
* @since v0.2.0
*/
- public final JTextField getSearchBox() {
+ public JTextField getSearchBox() {
return this.searchBox;
}
@@ -197,9 +197,8 @@ final class SearchBoxList<E> extends JPanel {
private Predicate<E> getSearchFilter(final String searchText) {
if (this.caseSensitive)
return item -> item.toString().contains(searchText);
- else
- return item -> item.toString().toLowerCase()
- .contains(searchText.toLowerCase());
+ return item -> item.toString().toLowerCase()
+ .contains(searchText.toLowerCase());
}
/**
@@ -207,7 +206,7 @@ final class SearchBoxList<E> extends JPanel {
* @since 2019-04-14
* @since v0.2.0
*/
- public final JList<E> getSearchList() {
+ public JList<E> getSearchList() {
return this.searchItems;
}
@@ -231,16 +230,16 @@ final class SearchBoxList<E> extends JPanel {
/**
* Re-applies the filters.
- *
+ *
* @since 2019-04-13
* @since v0.2.0
*/
public void reapplyFilter() {
- final String searchText = this.searchBoxEmpty ? ""
+ final var searchText = this.searchBoxEmpty ? ""
: this.searchBox.getText();
- final FilterComparator<E> comparator = new FilterComparator<>(searchText,
+ final var comparator = new FilterComparator<E>(searchText,
this.defaultOrdering, this.caseSensitive);
- final Predicate<E> searchFilter = this.getSearchFilter(searchText);
+ final var searchFilter = this.getSearchFilter(searchText);
this.listModel.clear();
this.itemsToFilter.forEach(item -> {
@@ -258,7 +257,7 @@ final class SearchBoxList<E> extends JPanel {
/**
* Runs whenever the search box gains focus.
- *
+ *
* @param e focus event
* @since 2019-04-13
* @since v0.2.0
@@ -273,7 +272,7 @@ final class SearchBoxList<E> extends JPanel {
/**
* Runs whenever the search box loses focus.
- *
+ *
* @param e focus event
* @since 2019-04-13
* @since v0.2.0
@@ -291,7 +290,7 @@ final class SearchBoxList<E> extends JPanel {
* <p>
* Reapplies the search filter, and custom filters.
* </p>
- *
+ *
* @since 2019-04-14
* @since v0.2.0
*/
@@ -299,11 +298,11 @@ final class SearchBoxList<E> extends JPanel {
if (this.searchBoxFocused) {
this.searchBoxEmpty = this.searchBox.getText().equals("");
}
- final String searchText = this.searchBoxEmpty ? ""
+ final var searchText = this.searchBoxEmpty ? ""
: this.searchBox.getText();
- final FilterComparator<E> comparator = new FilterComparator<>(searchText,
+ final var comparator = new FilterComparator<E>(searchText,
this.defaultOrdering, this.caseSensitive);
- final Predicate<E> searchFilter = this.getSearchFilter(searchText);
+ final var searchFilter = this.getSearchFilter(searchText);
// initialize list with items that match the filter then sort
this.listModel.clear();
@@ -336,7 +335,7 @@ final class SearchBoxList<E> extends JPanel {
/**
* Manually updates the search box's item list.
- *
+ *
* @since 2020-08-27
* @since v0.3.0
*/