change class to enum
This commit is contained in:
parent
2446c8aafa
commit
8dbe12bfb2
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -13,11 +13,11 @@ public class Main {
|
|||||||
|
|
||||||
|
|
||||||
System.out.println("Test Versions ...");
|
System.out.println("Test Versions ...");
|
||||||
Version.result A = Version.check(min_version,latest_version,"1.9.4");
|
Version A = Version.check(min_version,latest_version,"1.9.4");
|
||||||
Version.result B = Version.check(min_version,latest_version,"1.10.0+dev-414-gf1fdd782d");
|
Version B = Version.check(min_version,latest_version,"1.10.0+dev-414-gf1fdd782d");
|
||||||
Version.result C = Version.check(min_version,latest_version,"no-version-at-all");
|
Version C = Version.check(min_version,latest_version,"no-version-at-all");
|
||||||
Version.result D = Version.check(min_version,latest_version,"1.8.1");
|
Version D = Version.check(min_version,latest_version,"1.8.1");
|
||||||
Version.result E = Version.check(min_version,latest_version,"1.10.0");
|
Version E = Version.check(min_version,latest_version,"1.10.0");
|
||||||
|
|
||||||
System.out.println("1.9.4 = " + A.name());
|
System.out.println("1.9.4 = " + A.name());
|
||||||
System.out.println("1.10.0+dev-414-gf1fdd782d = " + B.name());
|
System.out.println("1.10.0+dev-414-gf1fdd782d = " + B.name());
|
||||||
|
@ -3,18 +3,17 @@ package com.company;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Version {
|
public enum Version {
|
||||||
public enum result{
|
UNKNOWN,
|
||||||
UNKNOWN,
|
SUPPORTED_LATEST,
|
||||||
SUPPORTED_LATEST,
|
SUPPORTED_OLD,
|
||||||
SUPPORTED_OLD,
|
DEVELOPMENT,
|
||||||
DEVELOPMENT,
|
UNSUPPORTED_OLD,
|
||||||
UNSUPPORTED_OLD,
|
UNSUPPORTED_NEW;
|
||||||
UNSUPPORTED_NEW
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static result check(String min, String last, String value) {
|
|
||||||
|
public static Version check(String min, String last, String value) {
|
||||||
|
|
||||||
final Pattern pattern_stable_release = Pattern.compile("^(\\d)\\.(\\d+)\\.(\\d+)$");
|
final Pattern pattern_stable_release = Pattern.compile("^(\\d)\\.(\\d+)\\.(\\d+)$");
|
||||||
final Pattern pattern_dev_release = Pattern.compile("^(\\d).(\\d+).(\\d+)(\\D)(.+)");
|
final Pattern pattern_dev_release = Pattern.compile("^(\\d).(\\d+).(\\d+)(\\D)(.+)");
|
||||||
@ -25,13 +24,13 @@ public class Version {
|
|||||||
|
|
||||||
switch (correlate(min, last, m.group())){
|
switch (correlate(min, last, m.group())){
|
||||||
case 0:
|
case 0:
|
||||||
return result.UNSUPPORTED_OLD;
|
return UNSUPPORTED_OLD;
|
||||||
case 1:
|
case 1:
|
||||||
return result.SUPPORTED_OLD;
|
return SUPPORTED_OLD;
|
||||||
case 2:
|
case 2:
|
||||||
return result.SUPPORTED_LATEST;
|
return SUPPORTED_LATEST;
|
||||||
default:
|
default:
|
||||||
return result.UNSUPPORTED_NEW;
|
return UNSUPPORTED_NEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -42,14 +41,14 @@ public class Version {
|
|||||||
m.find();
|
m.find();
|
||||||
|
|
||||||
if (correlate(min, last, m.group())>0) {
|
if (correlate(min, last, m.group())>0) {
|
||||||
return result.DEVELOPMENT;
|
return DEVELOPMENT;
|
||||||
} else {
|
} else {
|
||||||
return result.UNSUPPORTED_OLD;
|
return UNSUPPORTED_OLD;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.UNKNOWN;
|
return UNKNOWN;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
src/com/company/tst.java
Normal file
4
src/com/company/tst.java
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
package com.company;
|
||||||
|
|
||||||
|
public enum tst {
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user