001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.tools; 003 004/** 005 * Holder for current platform hook. 006 * @since 14138 007 */ 008public final class PlatformManager { 009 010 /** 011 * Platform specific code goes in here. 012 */ 013 private static final PlatformHook PLATFORM = Platform.determinePlatform().accept(PlatformHook.CONSTRUCT_FROM_PLATFORM); 014 015 private PlatformManager() { 016 // Hide constructor 017 } 018 019 /** 020 * Returns the current platform hook. 021 * @return the current platform hook 022 */ 023 public static PlatformHook getPlatform() { 024 return PLATFORM; 025 } 026 027 /** 028 * Determines if we are currently running on macOS. 029 * @return {@code true} if we are currently running on macOS 030 */ 031 public static boolean isPlatformOsx() { 032 return PLATFORM instanceof PlatformHookOsx; 033 } 034 035 /** 036 * Determines if we are currently running on an Unix system. 037 * @return {@code true} if we are currently running on an Unix system 038 */ 039 public static boolean isPlatformUnixoid() { 040 return PLATFORM instanceof PlatformHookUnixoid; 041 } 042 043 /** 044 * Determines if we are currently running on Windows. 045 * @return {@code true} if we are currently running on Windows 046 */ 047 public static boolean isPlatformWindows() { 048 return PLATFORM instanceof PlatformHookWindows; 049 } 050}