From da740edd3972fa049c4c8d0e43448c10a6a65dce Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Sun, 15 Jun 2025 19:26:12 -0500 Subject: Format & clean up source code --- src/main/java/sevenUnitsGUI/SearchBoxList.java | 47 +++++++++++++------------- 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'src/main/java/sevenUnitsGUI/SearchBoxList.java') 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 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 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 extends JPanel { /** * Creates an empty SearchBoxList - * + * * @since 2022-02-19 * @since v0.4.0 */ @@ -92,7 +92,7 @@ final class SearchBoxList 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 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 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 extends JPanel { /** * Resets the search filter. - * + * * @since 2019-04-13 * @since v0.2.0 */ @@ -183,7 +183,7 @@ final class SearchBoxList 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 extends JPanel { private Predicate 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 extends JPanel { * @since 2019-04-14 * @since v0.2.0 */ - public final JList getSearchList() { + public JList getSearchList() { return this.searchItems; } @@ -231,16 +230,16 @@ final class SearchBoxList 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 comparator = new FilterComparator<>(searchText, + final var comparator = new FilterComparator(searchText, this.defaultOrdering, this.caseSensitive); - final Predicate searchFilter = this.getSearchFilter(searchText); + final var searchFilter = this.getSearchFilter(searchText); this.listModel.clear(); this.itemsToFilter.forEach(item -> { @@ -258,7 +257,7 @@ final class SearchBoxList 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 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 extends JPanel { *

* Reapplies the search filter, and custom filters. *

- * + * * @since 2019-04-14 * @since v0.2.0 */ @@ -299,11 +298,11 @@ final class SearchBoxList 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 comparator = new FilterComparator<>(searchText, + final var comparator = new FilterComparator(searchText, this.defaultOrdering, this.caseSensitive); - final Predicate 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 extends JPanel { /** * Manually updates the search box's item list. - * + * * @since 2020-08-27 * @since v0.3.0 */ -- cgit v1.2.3