@Test public void testAccept() { final PathCondition TRUE = new FixedCondition(true); final PathCondition FALSE = new FixedCondition(false); assertTrue(IfAll.createAndCondition(TRUE, TRUE).accept(null, null, null)); assertFalse(IfAll.createAndCondition(FALSE, TRUE).accept(null, null, null)); assertFalse(IfAll.createAndCondition(TRUE, FALSE).accept(null, null, null)); assertFalse(IfAll.createAndCondition(FALSE, FALSE).accept(null, null, null)); }
@Test public void testEmptyIsFalse() { assertFalse(IfAll.createAndCondition().accept(null, null, null)); }
@Override public boolean accept(final Path baseDir, final Path relativePath, final BasicFileAttributes attrs) { if (components == null || components.length == 0) { return false; // unconditional delete not supported } return accept(components, baseDir, relativePath, attrs); }
@Override public boolean accept(final Path basePath, final Path relativePath, final BasicFileAttributes attrs) { final boolean result = ++count > threshold; final String match = result ? ">" : "<="; final String accept = result ? "ACCEPTED" : "REJECTED"; LOGGER.trace("IfAccumulatedFileCount {}: {} count '{}' {} threshold '{}'", accept, relativePath, count, match, threshold); if (result) { return IfAll.accept(nestedConditions, basePath, relativePath, attrs); } return result; }
@Override public boolean accept(final Path basePath, final Path relativePath, final BasicFileAttributes attrs) { final boolean result = pathMatcher.matches(relativePath); final String match = result ? "matches" : "does not match"; final String accept = result ? "ACCEPTED" : "REJECTED"; LOGGER.trace("IfFileName {}: '{}' {} relative path '{}'", accept, syntaxAndPattern, match, relativePath); if (result) { return IfAll.accept(nestedConditions, basePath, relativePath, attrs); } return result; }
@Override public boolean accept(final Path basePath, final Path relativePath, final BasicFileAttributes attrs) { accumulatedSize += attrs.size(); final boolean result = accumulatedSize > thresholdBytes; final String match = result ? ">" : "<="; final String accept = result ? "ACCEPTED" : "REJECTED"; LOGGER.trace("IfAccumulatedFileSize {}: {} accumulated size '{}' {} thresholdBytes '{}'", accept, relativePath, accumulatedSize, match, thresholdBytes); if (result) { return IfAll.accept(nestedConditions, basePath, relativePath, attrs); } return result; }
@Override public boolean accept(final Path basePath, final Path relativePath, final BasicFileAttributes attrs) { final FileTime fileTime = attrs.lastModifiedTime(); final long millis = fileTime.toMillis(); final long ageMillis = CLOCK.currentTimeMillis() - millis; final boolean result = ageMillis >= age.toMillis(); final String match = result ? ">=" : "<"; final String accept = result ? "ACCEPTED" : "REJECTED"; LOGGER.trace("IfLastModified {}: {} ageMillis '{}' {} '{}'", accept, relativePath, ageMillis, match, age); if (result) { return IfAll.accept(nestedConditions, basePath, relativePath, attrs); } return result; }