Skip to content

Commit c787874

Browse files
committed
Better version comparison
1 parent 14fbdb6 commit c787874

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

src/main/java/com/github/celldynamics/quimp/plugin/ecmm/ECMM_Mapping.java

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
public class ECMM_Mapping extends AbstractPluginQconf {
7676

7777
private static String thisPluginName = "ECMM Mapping";
78+
/**
79+
* Required version of IJ1.
80+
*/
81+
public static final String requiredVersion = "1.52n";
7882

7983
private File fileToLoad = null; // file to load paQP/QCONF
8084
/**
@@ -557,33 +561,14 @@ protected void runFromPaqp() throws QuimpException {
557561
@Override
558562
protected void validate() throws QuimpException {
559563
super.validate();
560-
boolean fail = false;
561564
String ver = IJ.getVersion();
565+
// strip ImageJ2 version from IJ1
562566
if (ver.indexOf("/") > -1) {
563567
ver = ver.substring(ver.indexOf("/") + 1);
564568
}
565-
LOGGER.info(ver);
566-
// assume letter code at the end
567-
try {
568-
if (Character.isLetter(ver.charAt(ver.length() - 1))) {
569-
String vern = ver.substring(0, ver.length() - 1); // should be 1.52 only
570-
if (Double.parseDouble(vern) < 1.52) {
571-
fail = true;
572-
} else {
573-
if (ver.charAt(ver.length() - 1) < 'n') {
574-
fail = true;
575-
}
576-
}
577-
} else {
578-
if (Double.parseDouble(ver) < 1.52) {
579-
fail = true;
580-
}
581-
}
582-
if (fail) {
583-
throw new QuimpException("IJ 1.52n version required (or above)");
584-
}
585-
} catch (NullPointerException | NumberFormatException e) {
586-
LOGGER.warn("Cannot process IJ version.");
569+
LOGGER.debug("IJ1 version " + ver);
570+
if (ver.compareTo(requiredVersion) < 0) {
571+
throw new QuimpException("Required ImageJ 1.52n (or above)");
587572
}
588573
}
589574

0 commit comments

Comments
 (0)