package oslib.osx;

import oslib.VersionCompare;

public enum OSXVersion implements VersionCompare {

    CHEETAH("Cheetah", "10.0"),
    PUMA("Puma", "10.1"),
    JAGUAR("Jaguar", "10.2"),
    PANTHER("Panther", "10.3"),
    TIGER("Tiger", "10.4"),
    LEOPARD("Leopard", "10.5"),
    SNOW_LEOPARD("Snow Leopard", "10.6"),
    LION("Lion", "10.7"),
    MOUNTAIN_LION("Mountain Lion", "10.8"),
    MAVERICKS("Mavericks", "10.9"),
    YOSEMITE("Yosemite", "10.10"),
    EL_CAPITAN("El Capitan", "10.11");

    private String search;
    private String version;

    private OSXVersion(String search, String version) {
        this.search = search;
        this.version = version;
    }

    /**
     * Returns codename, such as Yosemite
     *
     * @return
     */
    public String getDisplay() {
        return search;
    }

    /**
     * Version of OS X, such as 10.10
     *
     * @return
     */
    public String getVersion() {
        return version;
    }

    /**
     * Gets OSXVersion for this machine
     *
     * @return
     */
    public static OSXVersion getFromString() {
        return getFromString(System.getProperty("os.version"));
    }

    /**
     * Gets OSXVersion from string
     * Will detect "10.11.*" if parameter search is is "10.11"
     *
     * @param search Can either be version or display name ("10.10", "yosemite")
     * @return
     */
    public static OSXVersion getFromString(String search) {
        for (OSXVersion v : OSXVersion.values()) {
            if (search.startsWith(v.getVersion()) || v.getDisplay().toLowerCase().contains(search.toLowerCase())) {
                return v;
            }
        }

        return null;
    }

    public static OSXVersion getExact(String display, String version) {
        for (OSXVersion v : OSXVersion.values()) {
            if (v.getDisplay().equals(display) && v.getVersion().equals(version)) {
                return v;
            }
        }

        return null;
    }

    @Override
    public boolean isNewer(Enum<?> e) {
        return e.ordinal() > this.ordinal();
    }

    @Override
    public boolean isOlder(Enum<?> e) {
        return e.ordinal() < this.ordinal();
    }
}

@@ -124,16 +124,22 @@
 , %2210.0%22
+, true
 ),%0A    P
@@ -156,16 +156,22 @@
 , %2210.1%22
+, true
 ),%0A    J
@@ -192,16 +192,22 @@
 , %2210.2%22
+, true
 ),%0A    P
@@ -230,16 +230,22 @@
 , %2210.3%22
+, true
 ),%0A    T
@@ -264,16 +264,22 @@
 , %2210.4%22
+, true
 ),%0A    L
@@ -302,16 +302,22 @@
 , %2210.5%22
+, true
 ),%0A    S
@@ -350,16 +350,22 @@
 , %2210.6%22
+, true
 ),%0A    L
@@ -382,16 +382,22 @@
 , %2210.7%22
+, true
 ),%0A    M
@@ -432,16 +432,22 @@
 , %2210.8%22
+, true
 ),%0A    M
@@ -474,16 +474,22 @@
 , %2210.9%22
+, true
 ),%0A    Y
@@ -515,16 +515,22 @@
  %2210.10%22
+, true
 ),%0A    E
@@ -560,16 +560,53 @@
  %2210.11%22
+, true),%0A    SIERRA(%22Sierra%22, %2210.12%22
 );%0A%0A    
@@ -655,16 +655,41 @@
 version;
+%0A    private boolean isX;
 %0A%0A    pr
@@ -730,32 +730,146 @@
 ring version) %7B%0A
+        this(search, version, false);%0A    %7D%0A%0A    private OSXVersion(String search, String version, boolean isX) %7B%0A
         this.sea
@@ -906,32 +906,56 @@
 sion = version;%0A
+        this.isX = isX;%0A
     %7D%0A%0A    /**%0A 
@@ -1193,24 +1193,24 @@
 Version() %7B%0A
-
         retu
@@ -1220,32 +1220,203 @@
 version;%0A    %7D%0A%0A
+    /**%0A     * Indicates if this is Mac OS X or the newer macOS%0A     * @return if Mac OS X (%3C= 10.11)%0A     */%0A    public boolean isOSX() %7B%0A        return this.isX;%0A    %7D%0A%0A
     /**%0A     * G

Add macOS Sierra 10.12. Boolean flag in OSXVersion to indicate macOS or Mac OS X