return emptyIterator();
/** * Test empty iterator */ public void testEmptyIterator() { assertSame(EmptyIterator.INSTANCE, IteratorUtils.EMPTY_ITERATOR); assertSame(EmptyIterator.RESETTABLE_INSTANCE, IteratorUtils.EMPTY_ITERATOR); assertEquals(true, IteratorUtils.EMPTY_ITERATOR instanceof Iterator); assertEquals(true, IteratorUtils.EMPTY_ITERATOR instanceof ResettableIterator); assertEquals(false, IteratorUtils.EMPTY_ITERATOR instanceof OrderedIterator); assertEquals(false, (Object) IteratorUtils.EMPTY_ITERATOR instanceof ListIterator); assertEquals(false, (Object) IteratorUtils.EMPTY_ITERATOR instanceof MapIterator); assertEquals(false, IteratorUtils.EMPTY_ITERATOR.hasNext()); IteratorUtils.EMPTY_ITERATOR.reset(); assertSame(IteratorUtils.EMPTY_ITERATOR, IteratorUtils.EMPTY_ITERATOR); assertSame(IteratorUtils.EMPTY_ITERATOR, IteratorUtils.emptyIterator()); try { IteratorUtils.EMPTY_ITERATOR.next(); fail(); } catch (NoSuchElementException ex) {} try { IteratorUtils.EMPTY_ITERATOR.remove(); fail(); } catch (IllegalStateException ex) {} }
/** * Returns an iterator over parameter sets. Each element returned from the * iterator is a java.util.Map. */ @SuppressWarnings("unchecked") public Iterator<Map<String, ?>> parametersIterator() { return (parameters == null || parameters.length == 0) ? IteratorUtils.emptyIterator() : IteratorUtils .transformedIterator(IteratorUtils.arrayIterator(parameters), nullMapTransformer); }
/** * Returns an iterator over parameter sets. Each element returned from the iterator is * a java.util.Map. */ public Iterator parametersIterator() { return (parameters == null || parameters.length == 0) ? IteratorUtils .emptyIterator() : IteratorUtils.transformedIterator(IteratorUtils .arrayIterator(parameters), nullMapTransformer); }
/** * Returns an iterator over parameter sets. Each element returned from the iterator is * a java.util.Map. */ public Iterator parametersIterator() { return (parameters == null || parameters.length == 0) ? IteratorUtils .emptyIterator() : IteratorUtils.transformedIterator(IteratorUtils .arrayIterator(parameters), nullMapTransformer); }
@Override @SuppressWarnings("unchecked") public Iterator<N> getPreferredNodeIterator( CandidateNodeSet<N> candidateNodeSet) { // Now only handle the case that single node in the candidateNodeSet // TODO, Add support to multi-hosts inside candidateNodeSet which is passed // in. N singleNode = CandidateNodeSetUtils.getSingleNode(candidateNodeSet); if (null != singleNode) { return IteratorUtils.singletonIterator(singleNode); } return IteratorUtils.emptyIterator(); }
/** * Returns the value as an {@link Iterator}. If the value is itself an * iterator, an instance of {@link Iterable}, or is an array, the items in * the value will be returned as the list. Otherwise, if the value is not * <code>null</code>, it will be returned as the only item in the * iterator. If the value is <code>null</code>, an empty iterator is * returned. * * @param value The value to convert. * @return The iterator. */ @API public static Iterator<?> asIterator( Object value ) { if ( value instanceof Iterator ) { return (Iterator<?>) value; } else if ( value instanceof Iterable<?> ) { return ( (Iterable<?>) value ).iterator(); } else if ( value instanceof Enumeration ) { return IteratorUtils.asIterator( (Enumeration<?>) value ); } else if ( value != null ) { if ( value.getClass().isArray() ) { return IteratorUtils.arrayIterator( (Object[]) value ); } else { return Arrays.asList( value ).iterator(); } } else { return IteratorUtils.emptyIterator(); } }
/** * Returns an iterator over a snapshot copy of this group's collected events., optionally sorted by arrival order. If you need * to iterate over the group and e.g. remove select events, do so via {@link #removeEvent(CoreEvent)}. If you need to do so * atomically in order to prevent e.g. concurrent reception/aggregation of the group during iteration, wrap the iteration in a * synchronized block on the group instance. * * @return an iterator over collected {@link CoreEvent}s. * @throws ObjectStoreException */ @SuppressWarnings("unchecked") public Iterator<CoreEvent> iterator(boolean sortByArrival) throws ObjectStoreException { synchronized (this) { if (eventsObjectStore.allKeys(eventsPartitionKey).isEmpty()) { return IteratorUtils.emptyIterator(); } else { return IteratorUtils.arrayIterator(this.toArray(sortByArrival)); } } }
/** * Returns an iterator over a snapshot copy of this group's collected events., * optionally sorted by arrival order. If * you need to iterate over the group and e.g. remove select events, do so via * {@link #removeEvent(MuleEvent)}. If you need to do so atomically in order to * prevent e.g. concurrent reception/aggregation of the group during iteration, * wrap the iteration in a synchronized block on the group instance. * * @return an iterator over collected {@link MuleEvent}s. * @throws ObjectStoreException */ @SuppressWarnings("unchecked") public Iterator<MuleEvent> iterator(boolean sortByArrival) throws ObjectStoreException { synchronized (this) { if (eventsObjectStore.allKeys(eventsPartitionKey).isEmpty()) { return IteratorUtils.emptyIterator(); } else { return IteratorUtils.arrayIterator(this.toArray(sortByArrival)); } } }
return emptyIterator();
return IteratorUtils.emptyIterator();