mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-24 17:16:45 +00:00
move ostype to drongo
This commit is contained in:
parent
a26ba49bc6
commit
3cb3d322a0
1 changed files with 48 additions and 0 deletions
48
src/main/java/com/sparrowwallet/drongo/OsType.java
Normal file
48
src/main/java/com/sparrowwallet/drongo/OsType.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
package com.sparrowwallet.drongo;
|
||||
|
||||
public enum OsType {
|
||||
WINDOWS("Windows"),
|
||||
MACOS("macOS"),
|
||||
UNIX("Unix"),
|
||||
UNKNOWN("");
|
||||
|
||||
private static final OsType current = getCurrentPlatform();
|
||||
private final String platformId;
|
||||
|
||||
OsType(String platformId) {
|
||||
this.platformId = platformId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns platform id. Usually used to specify platform dependent styles
|
||||
*
|
||||
* @return platform id
|
||||
*/
|
||||
public String getPlatformId() {
|
||||
return platformId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current OS.
|
||||
*/
|
||||
public static OsType getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
private static OsType getCurrentPlatform() {
|
||||
String osName = System.getProperty("os.name");
|
||||
if(osName.startsWith("Windows")) {
|
||||
return WINDOWS;
|
||||
}
|
||||
if(osName.startsWith("Mac")) {
|
||||
return MACOS;
|
||||
}
|
||||
if(osName.startsWith("SunOS")) {
|
||||
return UNIX;
|
||||
}
|
||||
if(osName.startsWith("Linux")) {
|
||||
return UNIX;
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue