protect function with exeption
This commit is contained in:
parent
cab7b33ca5
commit
e9812f17ed
@ -26,7 +26,7 @@ public enum Version {
|
|||||||
Matcher m ;
|
Matcher m ;
|
||||||
|
|
||||||
if (!pattern_stable_release.matcher(min).find() || !pattern_stable_release.matcher(last).find()) {
|
if (!pattern_stable_release.matcher(min).find() || !pattern_stable_release.matcher(last).find()) {
|
||||||
throw new Error("VersionCheck: wrong format for min or last version given");
|
throw new IllegalArgumentException("VersionCheck: wrong format for min or last version given");
|
||||||
}
|
}
|
||||||
|
|
||||||
m = pattern_stable_release.matcher(value);
|
m = pattern_stable_release.matcher(value);
|
||||||
@ -74,7 +74,7 @@ public enum Version {
|
|||||||
|
|
||||||
switch (range_check) {
|
switch (range_check) {
|
||||||
case 2:
|
case 2:
|
||||||
throw new Error("Minimum Version higher than Last Version");
|
throw new IllegalArgumentException("Minimum Version higher than Last Version");
|
||||||
case 1: //min == last
|
case 1: //min == last
|
||||||
switch (min_check) {
|
switch (min_check) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -101,6 +101,9 @@ public enum Version {
|
|||||||
* 2 = more
|
* 2 = more
|
||||||
*/
|
*/
|
||||||
public static int compare(String A, String B) {
|
public static int compare(String A, String B) {
|
||||||
|
//throw new IllegalArgumentException
|
||||||
|
if((!A.matches("[0-9]+(\\.[0-9]+)*")) || (!B.matches("[0-9]+(\\.[0-9]+)*"))) throw new IllegalArgumentException("Invalid version format");
|
||||||
|
|
||||||
if (A.contains(".") || B.contains(".")) {
|
if (A.contains(".") || B.contains(".")) {
|
||||||
// example 2 vs 1.3
|
// example 2 vs 1.3
|
||||||
if (!(A.contains(".") && B.contains("."))) {
|
if (!(A.contains(".") && B.contains("."))) {
|
||||||
|
Loading…
Reference in New Issue
Block a user