001package com.github.sarxos.webcam.util;
002
003/**
004 * Just a simple enumeration with supported (not yet confirmed) operating
005 * systems.
006 * 
007 * @author Bartosz Firyn (sarxos)
008 */
009public enum OsUtils {
010
011        /**
012         * Microsoft Windows
013         */
014        WIN,
015
016        /**
017         * Linux or UNIX.
018         */
019        NIX,
020
021        /**
022         * Mac OS X
023         */
024        OSX;
025
026        private static OsUtils os = null;
027
028        /**
029         * Get operating system.
030         * 
031         * @return OS
032         */
033        public static final OsUtils getOS() {
034                if (os == null) {
035                        String osp = System.getProperty("os.name").toLowerCase();
036                        if (osp.indexOf("win") >= 0) {
037                                os = WIN;
038                        } else if (osp.indexOf("mac") >= 0) {
039                                os = OSX;
040                        } else if (osp.indexOf("nix") >= 0 || osp.indexOf("nux") >= 0) {
041                                os = NIX;
042                        } else {
043                                throw new RuntimeException(osp + " is not supported");
044                        }
045                }
046                return os;
047        }
048}