FIX typo, and renamed vars!

This commit is contained in:
leriomaggio
2021-08-28 20:58:06 +01:00
parent eea2b754ec
commit 924c57be70

View File

@@ -211,22 +211,22 @@ public final class CardEdition implements Comparable<CardEdition> {
// Now, for proper sorting, let's zero-pad the collector number (if integer) // Now, for proper sorting, let's zero-pad the collector number (if integer)
int collNr; int collNr;
String sortableCollNr = inputCollNumber; String sortableCollNr;
try { try {
collNr = Integer.parseInt(inputCollNumber); collNr = Integer.parseInt(inputCollNumber);
sortableCollNr = String.format("%05d", collNr); sortableCollNr = String.format("%05d", collNr);
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
String nonNumeric = sortableCollNr.replaceAll("[0-9]", ""); String nonNumSub = inputCollNumber.replaceAll("[0-9]", "");
String onlyNumeric = sortableCollNr.replaceAll("[^0-9]", ""); String onlyNumSub = inputCollNumber.replaceAll("[^0-9]", "");
try { try {
collNr = Integer.parseInt(onlyNumeric); collNr = Integer.parseInt(onlyNumSub);
} catch (NumberFormatException exon) { } catch (NumberFormatException exon) {
collNr = 0; // this is the case of ONLY-letters collector numbers collNr = 0; // this is the case of ONLY-letters collector numbers
} }
if ((collNr > 0) && (sortableCollNr.startsWith(onlyNumeric))) // e.g. 12a, 37+, 2018f, if ((collNr > 0) && (inputCollNumber.startsWith(onlyNumSub))) // e.g. 12a, 37+, 2018f,
sortableCollNr = String.format("%05d", collNr) + nonNumeric; sortableCollNr = String.format("%05d", collNr) + nonNumSub;
else // e.g. WS6, S1 else // e.g. WS6, S1
sortableCollNr = nonNumeric + String.format("%05d", collNr); sortableCollNr = nonNumSub + String.format("%05d", collNr);
} }
sortableCollNumberLookup.put(inputCollNumber, sortableCollNr); sortableCollNumberLookup.put(inputCollNumber, sortableCollNr);
return sortableCollNr; return sortableCollNr;