Fix designation sorting of various Cesaroni motors
This commit is contained in:
parent
ff83f2bad8
commit
4141b478f7
@ -20,8 +20,24 @@ public class DesignationComparator implements Comparator<String> {
|
||||
COLLATOR.setStrength(Collator.PRIMARY);
|
||||
}
|
||||
|
||||
/*
|
||||
* Regexp to parse the multitude of designations. Supported types:
|
||||
*
|
||||
* 1/4A4...
|
||||
* 1/2A4...
|
||||
* A4...
|
||||
* 132G100...
|
||||
* 132-G100...
|
||||
*
|
||||
* Capture groups:
|
||||
* 1 = garbage (stuff before impulse class)
|
||||
* 2 = divisor number for 1/2A, 1/4A etc, otherwise null
|
||||
* 3 = impulse class letter
|
||||
* 4 = average thrust
|
||||
* 5 = stuff after thrust number
|
||||
*/
|
||||
private Pattern pattern =
|
||||
Pattern.compile("^([0-9][0-9]+|1/([1-8]))?([a-zA-Z])([0-9]+)(.*?)$");
|
||||
Pattern.compile("^([0-9]+-?|1/([1-8]))?([a-zA-Z])([0-9,]+)(.*?)$");
|
||||
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
@ -34,11 +50,11 @@ public class DesignationComparator implements Comparator<String> {
|
||||
if (m1.find() && m2.find()) {
|
||||
|
||||
String o1Class = m1.group(3);
|
||||
int o1Thrust = Integer.parseInt(m1.group(4));
|
||||
int o1Thrust = Integer.parseInt(m1.group(4).replaceAll(",", ""));
|
||||
String o1Extra = m1.group(5);
|
||||
|
||||
String o2Class = m2.group(3);
|
||||
int o2Thrust = Integer.parseInt(m2.group(4));
|
||||
int o2Thrust = Integer.parseInt(m2.group(4).replaceAll(",", ""));
|
||||
String o2Extra = m2.group(5);
|
||||
|
||||
// 1. Motor class
|
||||
|
Loading…
x
Reference in New Issue
Block a user