Skip to content

Commit f111905

Browse files
committed
Removed a lot of useless equals overrides.
Those introduces a very convoluted logic that is needed only in two cases. Moreover those are better handled by directly checking the object.
1 parent cd3639a commit f111905

18 files changed

+7
-79
lines changed

app/src/cc/arduino/contributions/libraries/filters/CategoryPredicate.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,4 @@ public boolean test(ContributedLibrary input) {
4646
return input.getCategory() != null && category.equals(input.getCategory());
4747
}
4848

49-
@Override
50-
public boolean equals(Object obj) {
51-
return obj instanceof CategoryPredicate && ((CategoryPredicate) obj).category.equals(category);
52-
}
53-
5449
}

app/src/cc/arduino/contributions/libraries/filters/InstalledLibraryPredicate.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,4 @@ public boolean test(ContributedLibrary input) {
5151
.count() > 0;
5252
}
5353

54-
@Override
55-
public boolean equals(Object obj) {
56-
return obj instanceof InstalledLibraryPredicate;
57-
}
58-
5954
}

app/src/cc/arduino/contributions/libraries/filters/OnlyUpstreamReleasePredicate.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,4 @@ public boolean test(ContributedLibrary input) {
4141
return !(input instanceof UserLibrary);
4242
}
4343

44-
@Override
45-
public boolean equals(Object obj) {
46-
return obj instanceof OnlyUpstreamReleasePredicate;
47-
}
4844
}

app/src/cc/arduino/contributions/libraries/ui/DropdownInstalledLibraryItem.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,4 @@ public Predicate<ContributedLibrary> getFilterPredicate() {
4848
return new InstalledLibraryPredicate();
4949
}
5050

51-
@Override
52-
public boolean equals(Object obj) {
53-
return obj instanceof DropdownInstalledLibraryItem;
54-
}
55-
5651
}

app/src/cc/arduino/contributions/libraries/ui/DropdownLibraryOfCategoryItem.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,4 @@ public Predicate<ContributedLibrary> getFilterPredicate() {
5454
return new CategoryPredicate(category);
5555
}
5656

57-
@Override
58-
public boolean equals(Object obj) {
59-
return obj instanceof DropdownLibraryOfCategoryItem && ((DropdownLibraryOfCategoryItem) obj).category.equals(category);
60-
}
61-
6257
}

app/src/cc/arduino/contributions/libraries/ui/DropdownLibraryOfTypeItem.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,4 @@ public Predicate<ContributedLibrary> getFilterPredicate() {
5454
return new TypePredicate(type);
5555
}
5656

57-
@Override
58-
public boolean equals(Object obj) {
59-
return obj instanceof DropdownLibraryOfTypeItem && ((DropdownLibraryOfTypeItem) obj).type.equals(type);
60-
}
61-
6257
}

app/src/cc/arduino/contributions/libraries/ui/DropdownUpdatableLibrariesItem.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,4 @@ public String toString() {
4949
return tr("Updatable");
5050
}
5151

52-
@Override
53-
public boolean equals(Object obj) {
54-
return obj instanceof DropdownUpdatableLibrariesItem;
55-
}
56-
5752
}

app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public LibraryManagerUI(Frame parent, LibraryInstaller installer) {
118118
public void actionPerformed(ActionEvent event) {
119119
DropdownItem<ContributedLibrary> selected = (DropdownItem<ContributedLibrary>) typeChooser.getSelectedItem();
120120
previousRowAtPoint = -1;
121-
if (typeFilter == null || !typeFilter.equals(selected)) {
121+
if (typeFilter == null || typeFilter != selected.getFilterPredicate()) {
122122
typeFilter = selected.getFilterPredicate();
123123
if (contribTable.getCellEditor() != null) {
124124
contribTable.getCellEditor().stopCellEditing();
@@ -143,10 +143,10 @@ public void updateUI() {
143143
categoryChooser.removeActionListener(categoryChooserActionListener);
144144
typeChooser.removeActionListener(typeChooserActionListener);
145145

146-
categoryFilter = null;
147-
categoryChooser.removeAllItems();
148146

149147
// Load categories
148+
categoryFilter = x -> true;
149+
categoryChooser.removeAllItems();
150150
categoryChooser.addItem(new DropdownAllItem());
151151
Collection<String> categories = BaseNoGui.librariesIndexer.getIndex().getCategories();
152152
for (String category : categories) {
@@ -162,7 +162,7 @@ public void updateUI() {
162162
categoryChooser.setSelectedIndex(0);
163163
}
164164

165-
typeFilter = null;
165+
typeFilter = x -> true;
166166
typeChooser.removeAllItems();
167167
typeChooser.addItem(new DropdownAllItem());
168168
typeChooser.addItem(new DropdownUpdatableLibrariesItem());

app/src/cc/arduino/contributions/packages/filters/CategoryPredicate.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,4 @@ public boolean test(ContributedPlatform input) {
4646
return input.getCategory() != null && category.equals(input.getCategory());
4747
}
4848

49-
@Override
50-
public boolean equals(Object obj) {
51-
return obj instanceof CategoryPredicate && ((CategoryPredicate) obj).category.equals(category);
52-
}
53-
5449
}

app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,13 @@ public void updateUI() {
9898

9999
categoryChooser.removeActionListener(categoryChooserActionListener);
100100

101-
categoryFilter = null;
102-
categoryChooser.removeAllItems();
103-
104101
filterField.setEnabled(getContribModel().getRowCount() > 0);
105102

106103
categoryChooser.addActionListener(categoryChooserActionListener);
107104

108105
// Enable categories combo only if there are two or more choices
106+
categoryFilter = x -> true;
107+
categoryChooser.removeAllItems();
109108
categoryChooser.addItem(new DropdownAllCoresItem());
110109
categoryChooser.addItem(new DropdownUpdatableCoresItem());
111110
Collection<String> categories = BaseNoGui.indexer.getCategories();

0 commit comments

Comments
 (0)