@Override public Void call() throws GitAPIException { checkCallable(); List<Ref> refs = gitRepository.getRefs(Ref.class); List<Predicate<ReflogEntry>> refLogEntryFilterPredicates = new ArrayList<Predicate<ReflogEntry>>(); refLogEntryFilterPredicates.add(expireDatePredicate); refLogEntryFilterPredicates.add(new ReflogEntryFilterPredicateAdapter( reflogEntryFilter)); Predicate<ReflogEntry> refLogEntriesFilter = AllPredicate .allPredicate(refLogEntryFilterPredicates); try { for (Ref ref : refs) { List<ReflogEntry> reflogEntries = ref.getReflogEntries(); Iterator<ReflogEntry> reflogEntryIterator = reflogEntries .iterator(); Iterator<ReflogEntry> filteredReflogEntryIterator = IteratorUtils .filteredIterator(reflogEntryIterator, refLogEntriesFilter); List<ReflogEntry> nonFilteredReflogEntries = IteratorUtils .toList(filteredReflogEntryIterator); ref.clearReflog(); ref.addReflogEntries(nonFilteredReflogEntries); } } catch (IOException e) { throw new GitAPIException("Unable to read reflog entries", e) { private static final long serialVersionUID = 2266798959465371684L; }; } return null; }
@Test public void testGetPredicateWithSomeValuesIsAnyPredicate() throws Exception { // setup fixture = FilterPredicate.makeAccessPointsPredicate(settings); // execute Predicate<WiFiDetail> actual = ((FilterPredicate) fixture).getPredicate(); // validate assertTrue(actual instanceof AllPredicate); }
/** * Create a new Predicate that returns true only if all of the specified * predicates are true. * If the array of predicates is empty, then this predicate returns true. * * @param <T> the type that the predicate queries * @param predicates an array of predicates to check, may not be null * @return the <code>all</code> predicate * @throws NullPointerException if the predicates array is null * @throws NullPointerException if any predicate in the array is null * @see AllPredicate */ public static <T> Predicate<T> allPredicate(final Predicate<? super T>... predicates) { return AllPredicate.allPredicate(predicates); }
/** * Create a new Predicate that returns true only if all of the specified * predicates are true. The predicates are checked in iterator order. * If the collection of predicates is empty, then this predicate returns true. * * @param <T> the type that the predicate queries * @param predicates a collection of predicates to check, may not be null * @return the <code>all</code> predicate * @throws NullPointerException if the predicates collection is null * @throws NullPointerException if any predicate in the collection is null * @see AllPredicate */ public static <T> Predicate<T> allPredicate(final Collection<? extends Predicate<? super T>> predicates) { return AllPredicate.allPredicate(predicates); }