public void testRemoveFromFilteredIterator() { final Predicate myPredicate = new Predicate() { public boolean evaluate( Object object ) { Integer i = (Integer) object; if (i.compareTo(new Integer(4)) < 0) return true; return false; } }; List list1 = new ArrayList(); List list2 = new ArrayList(); list1.add(new Integer(1)); list1.add(new Integer(2)); list2.add(new Integer(3)); list2.add(new Integer(4)); // will be ignored by the predicate Iterator it1 = IteratorUtils.filteredIterator(list1.iterator(), myPredicate ); Iterator it2 = IteratorUtils.filteredIterator(list2.iterator(), myPredicate ); Iterator it = IteratorUtils.chainedIterator(it1, it2); while (it.hasNext()) { it.next(); it.remove(); } assertEquals( 0, list1.size() ); assertEquals( 1, list2.size() ); }
public List<SearchSort> concatSearchSorts(final Collection<SearchSort> newSorts, final Collection<SearchSort> oldSorts, final int maxLength) { // like merge, except we don't bother checking for duplicates - just join the two collections together (new then old) Assertions.notNull("newSorts", newSorts); Iterator<SearchSort> source = newSorts.iterator(); if (oldSorts != null) { source = IteratorUtils.chainedIterator(source, oldSorts.iterator()); } final List<SearchSort> calcSorts = new ArrayList<SearchSort>(); while (calcSorts.size() < maxLength && source.hasNext()) { calcSorts.add(source.next()); } return calcSorts; }
public Iterator getProperties() { Iterator declaredIt = IteratorUtils.unmodifiableIterator(declaredProperties .values() .iterator()); if (getSuperclassDescriptor() == null) { return declaredIt; } else { return IteratorUtils.chainedIterator( superclassDescriptor.getProperties(), declaredIt); } }
public Iterator getProperties() { Iterator declaredIt = IteratorUtils.unmodifiableIterator(declaredProperties .values() .iterator()); if (getSuperclassDescriptor() == null) { return declaredIt; } else { return IteratorUtils.chainedIterator( superclassDescriptor.getProperties(), declaredIt); } }
source = IteratorUtils.chainedIterator(newSorts.iterator(), oldSorts.iterator());
@Override @SuppressWarnings("unchecked") public Iterator<String> iterator() { Iterator<String> it; final Iterator<String> resourceTypeIterator = typeHierarchyOf(this.resource); final Node node = this.resource.adaptTo(Node.class); // A virtual resource must not have a node. if (node != null) { final Iterator<String> nodeTypeIterator = typeHierarchyOf(node); it = IteratorUtils.chainedIterator(resourceTypeIterator, nodeTypeIterator); } else { it = resourceTypeIterator; } return it; } }
Map<String, String> accountNumberToChartCodeCache = new HashMap<String, String>(); Iterator<Object> originEntryAndDetailIterator = IteratorUtils.chainedIterator(collectorBatch.getOriginEntries().iterator(), collectorBatch.getCollectorDetails().iterator()); while (originEntryAndDetailIterator.hasNext()) { Object originEntryOrDetail = originEntryAndDetailIterator.next();
return IteratorUtils.filteredIterator(IteratorUtils.chainedIterator(allChildren), new Predicate() { private Set<String> names = new HashSet<>(); @Override
Iterator children = IteratorUtils.chainedIterator(childIterators); if (!children.hasNext()) { return null;