package util;

public class PlatformSpecific {

//    private static final PlatformSpecific instance = new PlatformSpecific();
    private PlatformSpecific() {}
    private static final String osName = System.getProperty("os.name");

    public static boolean isOnWindows() {
        return osName.startsWith("Windows");
    }

    public static boolean isOnMac() {
        return osName.startsWith("Mac OS");
    }

//    public static boolean isOnLinux() {
//        return !isOnWindows() && !isOnMac();
//    }

//    public static PlatformSpecific ifWindows(Runnable code) {
//        if (isOnWindows()) {
//            code.run();
//        }
//        return instance;
//    }

//    public static PlatformSpecific ifMac(Runnable code) {
//        if (isOnMac()) {
//            code.run();
//        }
//        return instance;
//    }

//    public static PlatformSpecific ifLinux(Runnable code) {
//        if (isOnLinux()) {
//            code.run();
//        }
//        return instance;
//    }
}

@@ -12,39 +12,250 @@
 l;%0A%0A
-public class PlatformSpecific %7B
+import java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader;%0A%0Aimport org.apache.logging.log4j.Logger;%0A%0Apublic class PlatformSpecific %7B%0A    private static final Logger logger = HTLog.get(PlatformSpecific.class);
 %0A%0A//
@@ -438,16 +438,97 @@
 ame%22);%0A%0A
+    public static enum Architecture %7B%0A        UNKNOWN, X86_64, I386, I686%0A    %7D%0A%0A
     publ
@@ -698,26 +698,24 @@
 S%22);%0A    %7D%0A%0A
-//
     public s
@@ -728,24 +728,30 @@
 boolean isOn
+64Bits
 Linux() %7B%0A//
@@ -752,57 +752,2087 @@
 ) %7B%0A
-//        return !isOnWindows() && !isOnMac();%0A//
+        if (!isOnLinux()) %7B%0A            return false;%0A        %7D%0A%0A        return getLinuxKernelArchitecture() == Architecture.X86_64;%0A    %7D%0A%0A    private static boolean isOnLinux() %7B%0A        return osName.startsWith(%22Linux%22);%0A    %7D%0A%0A    private static Architecture getLinuxKernelArchitecture() %7B%0A        try %7B%0A            Process process = Runtime.getRuntime().exec(%22uname -m%22);%0A            process.waitFor();%0A%0A            BufferedReader reader =%0A                    new BufferedReader(new InputStreamReader(process.getInputStream()));%0A%0A            String output = %22%22;%0A            String nextOutputLine = reader.readLine();%0A%0A            while (nextOutputLine != null) %7B%0A                output += nextOutputLine + %22 %22;%0A                nextOutputLine = reader.readLine();%0A            %7D%0A%0A            return getArchitectureFromString(output);%0A        %7D catch (IOException e) %7B%0A            logger.error(%22Unable to get linux kernel architecture%22);%0A            logger.error(e.getLocalizedMessage());%0A%0A            return Architecture.UNKNOWN;%0A        %7D catch (InterruptedException e) %7B%0A            logger.error(%22Unable to get linux kernel architecture%22);%0A            logger.error(e.getLocalizedMessage());%0A%0A            return Architecture.UNKNOWN;%0A        %7D%0A    %7D%0A%0A    /**%0A     * Finds a relevant sub-string that characterizes an os architecture and%0A     * return the corresponding Architecture enum%0A     * @param architectureDescription a string description of an os architecture%0A     * @return the corresponding Architecture enum%0A     */%0A    public static Architecture getArchitectureFromString(String architectureDescription) %7B%0A        if (architectureDescription == null) %7B%0A            return Architecture.UNKNOWN;%0A        %7D if (architectureDescription.contains(%22x86_64%22)) %7B%0A            return Architecture.X86_64;%0A        %7D else if (architectureDescription.contains(%22i386%22)) %7B%0A            return Architecture.I386;%0A        %7D else if (architectureDescription.contains(%22i686%22)) %7B%0A            return Architecture.I686;%0A        %7D else %7B%0A            return Architecture.UNKNOWN;%0A        %7D%0A
     

Implement method to obtain linux kernel's architecture