@Test public void declinesDirectoriesWithNamesLowerThanLowestLegalPid() { int[] illegalPids = { Short.MIN_VALUE, -1, 0 }; for (Integer illegalPid : illegalPids) { boolean result = procPathFilter.accept(true, illegalPid.toString()); 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);  }