CrossPlatformCommand¶
- public abstract class CrossPlatformCommand<T>¶
A command that when run will execute the proper method for the specified operating system. This is especially useful when you are trying to create for handling different platforms. Here is an example usage of the class:
final Boolean result = new CrossPlatformCommand<Boolean>() { @Override protected Boolean onWindows() { //do your logic for windows } @Override protected Boolean onUnix() { //do your logic for unix } @Override protected Boolean onMac() { //do your logic for mac } @Override protected Boolean onSolaris() { //do your logic for solaris } }.execute();
Parameters: - <T> – the result from the command.
Methods¶
execute¶
- public T execute()¶
Main method that should be executed. This will return the proper result depending on your platform.
Returns: the result
isMac¶
- public static boolean isMac()¶
Check if the current OS is MacOS.
Returns: true if macOS and false otherwise
isSolaris¶
- public static boolean isSolaris()¶
Check if the current OS is Solaris.
Returns: true if solaris and false otherwise
isUnix¶
- public static boolean isUnix()¶
Check if the current OS is some sort of unix.
Returns: true if unix and false otherwise