/** * Fetch the current Operating System * * @return The current operating system */ public OperatingSystem fetchCurrentOperationSystem() { return OperatingSystem.fromString(System.getProperty("os.name")); } }
/** * Creates a Operating System from the name * * @param fullName The name * @return The operating system */ public static OperatingSystem fromString(String fullName) { for (OperatingSystem system : OperatingSystem.values()) { if (system.getFullName().equals(fullName)) { return system; } } throw new IllegalArgumentException(String.format("Incompatible operation system \"%s\"", fullName)); }