@Test public void declinesDirectoriesWithNumbersGreaterThanPidMax() { String[] illegalNames = { (pidMax + 1) + "", (Integer.MAX_VALUE) + "", "1581293129481285417512948151274129849812" }; for (String illegalName : illegalNames) { boolean result = procPathFilter.accept(true, illegalName); assertFalse(result); } }
boolean accept(boolean isDirectory, String fileName) { if (!isDirectory) { return false; } Integer numericalPid = tryParseInt(fileName); return numericalPid != null && numericalPid >= LinuxConstants.LOWEST_LEGAL_PID && numericalPid < pidMax; }
ProcPathFilter implements BiPredicate<Path, BasicFileAttributes> { boolean accept(boolean isDirectory, String fileName) { if (!isDirectory) { return false; } Integer numericalPid = tryParseInt(fileName); return numericalPid != null && numericalPid >= LinuxConstants.LOWEST_LEGAL_PID && numericalPid < pidMax; } }
ProcPathFilter implements BiPredicate<Path, BasicFileAttributes> { boolean accept(boolean isDirectory, String fileName) { if (!isDirectory) { return false; } Integer numericalPid = tryParseInt(fileName); return numericalPid != null && numericalPid >= LinuxConstants.LOWEST_LEGAL_PID && numericalPid < pidMax; } ProcPathFilter(int pidMax); }
ProcPathFilter implements BiPredicate<Path, BasicFileAttributes> { boolean accept(boolean isDirectory, String fileName) { if (!isDirectory) { return false; } Integer numericalPid = tryParseInt(fileName); return numericalPid != null && numericalPid >= LinuxConstants.LOWEST_LEGAL_PID && numericalPid < pidMax; } ProcPathFilter(int pidMax); @Override boolean test(Path path, BasicFileAttributes basicFileAttributes); }
ProcPathFilter implements BiPredicate<Path, BasicFileAttributes> { boolean accept(boolean isDirectory, String fileName) { if (!isDirectory) { return false; } Integer numericalPid = tryParseInt(fileName); return numericalPid != null && numericalPid >= LinuxConstants.LOWEST_LEGAL_PID && numericalPid < pidMax; } ProcPathFilter(int pidMax); @Override boolean test(Path path, BasicFileAttributes basicFileAttributes);  }