-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Sorting of read-status isn't working as expected #4521 *Created Comparator for Read Status by adding new class *Added above comparator to read status column Signed-off-by: Aman Jain <[email protected]> * Update CHANGELOG.md Remove redundant code in ReadStatusFieldComparator.java as suggested Signed-off-by: Aman Jain <[email protected]> * Update CHANGELOG.md
- Loading branch information
1 parent
57d60fa
commit 49c3ef3
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/org/jabref/gui/util/comparator/ReadStatusFieldComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.jabref.gui.util.comparator; | ||
|
||
import java.util.Comparator; | ||
import java.util.Optional; | ||
|
||
import org.jabref.gui.specialfields.SpecialFieldValueViewModel; | ||
|
||
public class ReadStatusFieldComparator implements Comparator<Optional<SpecialFieldValueViewModel>> { | ||
|
||
@Override | ||
public int compare(Optional<SpecialFieldValueViewModel> val1, Optional<SpecialFieldValueViewModel> val2) { | ||
if (val1.isPresent()) { | ||
if (val2.isPresent()) { | ||
return val1.get().getValue().compareTo(val2.get().getValue()); | ||
} else { | ||
return -1; | ||
} | ||
} else { | ||
if (val2.isPresent()) { | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
} | ||
} | ||
|
||
} |