mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-23 12:52:13 +01:00
24 lines
558 B
Java
24 lines
558 B
Java
|
package cc.arduino.contributions;
|
||
|
|
||
|
import com.github.zafarkhaja.semver.Version;
|
||
|
|
||
|
public class VersionHelper {
|
||
|
|
||
|
public static Version valueOf(String ver) {
|
||
|
if (ver == null) {
|
||
|
return null;
|
||
|
}
|
||
|
String[] verParts = ver.split("\\.");
|
||
|
if (verParts.length < 3) {
|
||
|
if (verParts.length == 2) {
|
||
|
return Version.forIntegers(Integer.valueOf(verParts[0]), Integer.valueOf(verParts[1]));
|
||
|
} else {
|
||
|
return Version.forIntegers(Integer.valueOf(verParts[0]));
|
||
|
}
|
||
|
} else {
|
||
|
return Version.valueOf(ver);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|