All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.bdeploy.common.util.OsHelper Maven / Gradle / Ivy

Go to download

Public API including dependencies, ready to be used for integrations and plugins.

There is a newer version: 7.3.6
Show newest version
package io.bdeploy.common.util;

import com.fasterxml.jackson.annotation.JsonEnumDefaultValue;

/**
 * Determines OS specifics.
 */
public class OsHelper {

    public enum OperatingSystem {
        WINDOWS,
        LINUX,
        AIX,
        MACOS,
        @JsonEnumDefaultValue
        UNKNOWN
    }

    private OsHelper() {
    }

    /**
     * @return the currently running {@link OperatingSystem}.
     */
    public static OperatingSystem getRunningOs() {
        String prop = System.getProperty("os.name").toUpperCase();
        if (prop.contains("WINDOWS")) {
            return OperatingSystem.WINDOWS;
        } else if (prop.contains("LINUX")) {
            return OperatingSystem.LINUX;
        } else if (prop.contains("AIX")) {
            return OperatingSystem.AIX;
        } else if (prop.contains("MAC")) {
            return OperatingSystem.MACOS;
        }

        throw new IllegalStateException("Unsupported OS: " + prop);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy