Platform { static ID getPlatformId(String osName) { String osNameLC = osName.toLowerCase(); for (ID platformId : ID.values()) { if (osNameLC.startsWith(platformId.osNamePattern)) { return platformId; } } return null; } Platform(ID id, int bitCount); ID getId(); int getBitCount(); boolean isPlatformDir(String entryName); String truncatePlatformDir(String entryName); static boolean isAnyPlatformDir(String entryName); static Platform getCurrentPlatform();  }
@Test public void testToPlatformId() throws Exception { assertEquals(Platform.ID.linux, Platform.getPlatformId("Linux")); assertEquals(Platform.ID.macosx, Platform.getPlatformId("Mac OS X")); assertEquals(Platform.ID.win, Platform.getPlatformId("Windows 7")); assertEquals(Platform.ID.win, Platform.getPlatformId("Windows Vista")); assertEquals(null, Platform.getPlatformId("Vindows Wista")); try { Platform.getPlatformId(null); fail("NPE?"); } catch (NullPointerException e) { } }