change class to enum

This commit is contained in:
6543 2019-10-13 15:12:48 +02:00
parent 2446c8aafa
commit 8dbe12bfb2
Signed by: 6543
GPG Key ID: A1CA74D27FD13271
4 changed files with 31 additions and 22 deletions

6
.idea/vcs.xml generated Normal file
View 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>

View File

@ -13,11 +13,11 @@ public class Main {
System.out.println("Test Versions ...");
Version.result 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.result C = Version.check(min_version,latest_version,"no-version-at-all");
Version.result D = Version.check(min_version,latest_version,"1.8.1");
Version.result E = Version.check(min_version,latest_version,"1.10.0");
Version A = Version.check(min_version,latest_version,"1.9.4");
Version B = Version.check(min_version,latest_version,"1.10.0+dev-414-gf1fdd782d");
Version C = Version.check(min_version,latest_version,"no-version-at-all");
Version D = Version.check(min_version,latest_version,"1.8.1");
Version E = Version.check(min_version,latest_version,"1.10.0");

System.out.println("1.9.4 = " + A.name());
System.out.println("1.10.0+dev-414-gf1fdd782d = " + B.name());

View File

@ -3,18 +3,17 @@ package com.company;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Version {
public enum result{
UNKNOWN,
SUPPORTED_LATEST,
SUPPORTED_OLD,
DEVELOPMENT,
UNSUPPORTED_OLD,
UNSUPPORTED_NEW
}
public enum Version {
UNKNOWN,
SUPPORTED_LATEST,
SUPPORTED_OLD,
DEVELOPMENT,
UNSUPPORTED_OLD,
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_dev_release = Pattern.compile("^(\\d).(\\d+).(\\d+)(\\D)(.+)");
@ -25,13 +24,13 @@ public class Version {

switch (correlate(min, last, m.group())){
case 0:
return result.UNSUPPORTED_OLD;
return UNSUPPORTED_OLD;
case 1:
return result.SUPPORTED_OLD;
return SUPPORTED_OLD;
case 2:
return result.SUPPORTED_LATEST;
return SUPPORTED_LATEST;
default:
return result.UNSUPPORTED_NEW;
return UNSUPPORTED_NEW;
}

}
@ -42,14 +41,14 @@ public class Version {
m.find();

if (correlate(min, last, m.group())>0) {
return result.DEVELOPMENT;
return DEVELOPMENT;
} else {
return result.UNSUPPORTED_OLD;
return UNSUPPORTED_OLD;
}

}

return result.UNKNOWN;
return UNKNOWN;

}


4
src/com/company/tst.java Normal file
View File

@ -0,0 +1,4 @@
package com.company;

public enum tst {
}