Enum OS

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<OS>

    public enum OS
    extends java.lang.Enum<OS>
    Enum representing an OS and its underlying CPU architecture.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String arch()
      SWT-style x86/x86_64
      static void detectPlatform​(java.util.function.Function<java.lang.String,​java.lang.String> systemProperty, java.util.function.Function<java.lang.String,​java.lang.String> environmentVariable)
      Eagerly detects the native and running JVM properties.
      Arch getArch()
      Returns the architecture of the given operating system.
      static OS getNative()
      Returns the native OS: 32-bit JVM on 64-bit Windows returns OS.WIN_64.
      static OS getRunning()
      Returns the running OS: 32-bit JVM on 64-bit Windows returns OS.WIN_32.
      boolean isLinux()  
      boolean isMac()  
      boolean isMacOrLinux()  
      boolean isWindows()  
      static void main​(java.lang.String[] args)  
      java.lang.String os()
      SWT-style win32/linux/macosx
      java.lang.String osDotArch()
      os().arch()
      java.lang.String toSwt()
      windowing.os.arch
      static java.lang.UnsupportedOperationException unsupportedException​(OS os)
      Returns an UnsupportedOperationException for the given OS.
      static OS valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static OS[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      <T> T winMacLinux​(T win, T mac, T linux)
      Returns the appropriate value depending on the OS.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • WIN_x64

        public static final OS WIN_x64
      • WIN_x86

        public static final OS WIN_x86
      • LINUX_x64

        public static final OS LINUX_x64
      • LINUX_x86

        public static final OS LINUX_x86
      • MAC_x64

        public static final OS MAC_x64
      • MAC_silicon

        public static final OS MAC_silicon
      • WIN_unknown

        public static final OS WIN_unknown
      • LINUX_unknown

        public static final OS LINUX_unknown
      • MAC_unknown

        public static final OS MAC_unknown
    • Method Detail

      • values

        public static OS[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (OS c : OS.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static OS valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • isWindows

        public boolean isWindows()
      • isLinux

        public boolean isLinux()
      • isMac

        public boolean isMac()
      • isMacOrLinux

        public boolean isMacOrLinux()
      • winMacLinux

        public <T> T winMacLinux​(T win,
                                 T mac,
                                 T linux)
        Returns the appropriate value depending on the OS.
      • getArch

        public Arch getArch()
        Returns the architecture of the given operating system.
      • os

        public java.lang.String os()
        SWT-style win32/linux/macosx
      • arch

        public java.lang.String arch()
        SWT-style x86/x86_64
      • osDotArch

        public java.lang.String osDotArch()
        os().arch()
      • toSwt

        public java.lang.String toSwt()
        windowing.os.arch
      • getNative

        public static OS getNative()
        Returns the native OS: 32-bit JVM on 64-bit Windows returns OS.WIN_64.
      • getRunning

        public static OS getRunning()
        Returns the running OS: 32-bit JVM on 64-bit Windows returns OS.WIN_32.
      • detectPlatform

        public static void detectPlatform​(java.util.function.Function<java.lang.String,​java.lang.String> systemProperty,
                                          java.util.function.Function<java.lang.String,​java.lang.String> environmentVariable)
        Eagerly detects the native and running JVM properties.
      • unsupportedException

        public static java.lang.UnsupportedOperationException unsupportedException​(OS os)
        Returns an UnsupportedOperationException for the given OS.
      • main

        public static void main​(java.lang.String[] args)