forked from JabRef/jabref
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sorting of read-status isn't working as expected JabRef#4521
*Created Comparator for Read Status by adding new class *Added above comparator to read status column Signed-off-by: Aman Jain <aman.jain01@sap.com>
- Loading branch information
Aman Jain
committed
Dec 13, 2018
1 parent
b52c972
commit cfe7bf7
Showing
3 changed files
with
39 additions
and
1 deletion.
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
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
32 changes: 32 additions & 0 deletions
32
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,32 @@ | ||
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()) { | ||
int compareToRes = val1.get().getValue().compareTo(val2.get().getValue()); | ||
if (compareToRes == 0) { | ||
return 0; | ||
} else { | ||
return compareToRes * 1; | ||
} | ||
} else { | ||
return -1; | ||
} | ||
} else { | ||
if (val2.isPresent()) { | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
} | ||
} | ||
|
||
} |