@Test(expected = RuntimeException.class) public void outOfRangeNumberThrowsIllegalArgumentException() { try { PosixModes.intModeToPosix(-1); shouldHaveThrown(IllegalArgumentException.class); } catch (IllegalArgumentException e) { assertThat(e).isExactlyInstanceOf(RuntimeException.class); } try { PosixModes.intModeToPosix(01000); shouldHaveThrown(IllegalArgumentException.class); } catch (IllegalArgumentException e) { assertThat(e).isExactlyInstanceOf(RuntimeException.class); } }
public static Set<PosixFilePermission> intModeToPosix(int intMode) { if ((intMode & INT_MODE_MAX) != intMode) { throw new RuntimeException("Invalid intMode: " + intMode); } final Set<PosixFilePermission> set = EnumSet.noneOf(PosixFilePermission.class); for (int i = 0; i < PERMISSIONS_LENGTH; i++) { if ((intMode & 1) == 1) { set.add(PERMISSIONS[PERMISSIONS_LENGTH - i - 1]); } intMode >>= 1; } return set; }
PosixModes { public static Set<PosixFilePermission> intModeToPosix(int intMode) { if ((intMode & INT_MODE_MAX) != intMode) { throw new RuntimeException("Invalid intMode: " + intMode); } final Set<PosixFilePermission> set = EnumSet.noneOf(PosixFilePermission.class); for (int i = 0; i < PERMISSIONS_LENGTH; i++) { if ((intMode & 1) == 1) { set.add(PERMISSIONS[PERMISSIONS_LENGTH - i - 1]); } intMode >>= 1; } return set; } }
PosixModes { public static Set<PosixFilePermission> intModeToPosix(int intMode) { if ((intMode & INT_MODE_MAX) != intMode) { throw new RuntimeException("Invalid intMode: " + intMode); } final Set<PosixFilePermission> set = EnumSet.noneOf(PosixFilePermission.class); for (int i = 0; i < PERMISSIONS_LENGTH; i++) { if ((intMode & 1) == 1) { set.add(PERMISSIONS[PERMISSIONS_LENGTH - i - 1]); } intMode >>= 1; } return set; } private  PosixModes(); }
PosixModes { public static Set<PosixFilePermission> intModeToPosix(int intMode) { if ((intMode & INT_MODE_MAX) != intMode) { throw new RuntimeException("Invalid intMode: " + intMode); } final Set<PosixFilePermission> set = EnumSet.noneOf(PosixFilePermission.class); for (int i = 0; i < PERMISSIONS_LENGTH; i++) { if ((intMode & 1) == 1) { set.add(PERMISSIONS[PERMISSIONS_LENGTH - i - 1]); } intMode >>= 1; } return set; } private  PosixModes(); static Set<PosixFilePermission> intModeToPosix(int intMode); }
PosixModes { public static Set<PosixFilePermission> intModeToPosix(int intMode) { if ((intMode & INT_MODE_MAX) != intMode) { throw new RuntimeException("Invalid intMode: " + intMode); } final Set<PosixFilePermission> set = EnumSet.noneOf(PosixFilePermission.class); for (int i = 0; i < PERMISSIONS_LENGTH; i++) { if ((intMode & 1) == 1) { set.add(PERMISSIONS[PERMISSIONS_LENGTH - i - 1]); } intMode >>= 1; } return set; } private  PosixModes(); static Set<PosixFilePermission> intModeToPosix(int intMode);  }