/** * Returns an <code>Iterator</code> over the elements of the * product of the specified collections with the left one * controlling the outer loop. This factory method is preferable * when the left collection is more expensive to use than the * right one. */ public static final Iterator leftIterator( Collection left, Collection right ) { if( left == null ) { throw new IllegalArgumentException( "Left operand is null." ); } if( right == null ) { throw new IllegalArgumentException( "Right operand is null." ); } Iterator leftIter = left.iterator(); // We have to check for this case, because passing an empty // right collection to the Iterator constructor would result // in incorrect behavior for hasNext() as it is written. The // alternative is a more complex Iterator implementation. if( !leftIter.hasNext() || right.isEmpty() ) { return EmptyIterator.INSTANCE; } return new LeftIterator( leftIter, right ); }
/** * Returns an <code>Iterator</code> over the elements of the * product of the specified collections with the right one * controlling the outer loop. This factory method is preferable * when the right collection is more expensive to use than the * left one. */ public static final Iterator rightIterator( Collection left, Collection right ) { if( left == null ) { throw new IllegalArgumentException( "Left operand is null." ); } if( right == null ) { throw new IllegalArgumentException( "Right operand is null." ); } Iterator rightIter = right.iterator(); // We have to check for this case, because passing an empty // left collection to the Iterator constructor would result // in incorrect behavior for hasNext() as it is written. The // alternative is a more complex Iterator implementation. if( !rightIter.hasNext() || left.isEmpty() ) { return EmptyIterator.INSTANCE; } return new RightIterator( left, rightIter ); }
/** * Creates an entry set iterator. * Subclasses can override this to return iterators with different properties. * * @return the entrySet iterator */ protected Iterator createEntrySetIterator() { if (size() == 0) { return EmptyIterator.INSTANCE; } return new EntrySetIterator(this); }
/** * Creates a key set iterator. * Subclasses can override this to return iterators with different properties. * * @return the keySet iterator */ protected Iterator createKeySetIterator() { if (size() == 0) { return EmptyIterator.INSTANCE; } return new KeySetIterator(this); }
/** * Creates a values iterator. * Subclasses can override this to return iterators with different properties. * * @return the values iterator */ protected Iterator createValuesIterator() { if (size() == 0) { return EmptyIterator.INSTANCE; } return new ValuesIterator(this); }
public Iterator iterator() { return isEmpty() ? EmptyIterator.INSTANCE : new IteratorChain( new Iterator[] { new UnmodifiableIterator( left.edges( null ).iterator() ), new UnmodifiableIterator( right.edges( null ).iterator() ), new CrossEdgeIterator() } ); }
/** * Returns an iterator over all super classes of the class specified by the * given uri or an empty iterator if no such class exists or if it has no * super classes. * * @param uri * @return an iterator over all super classes of the class specified by the * given uri or an empty iterator if no such class exists or if it * has no super classes. */ @SuppressWarnings("unchecked") public Iterator<OntClass> getSuperClasses(String uri) { OntModel model = OntologyIndex.get().getModel(); OntClass clazz = model.getOntClass(uri); if (clazz != null) { return clazz.listSuperClasses(true); } return EmptyIterator.INSTANCE; }
/** * Returns an iterator over all subclasses of the class specified by the * given uri or an empty iterator if no such class exists or if it has no * subclasses. * * @param uri * @return an iterator over all super classes of the class specified by the * given uri or an empty iterator if no such class exists or if it * has no super classes. */ @SuppressWarnings("unchecked") public Iterator<OntClass> getSubClasses(String uri) { OntModel model = OntologyIndex.get().getModel(); OntClass clazz = model.getOntClass(uri); if (clazz != null) { return clazz.listSubClasses(true); } return EmptyIterator.INSTANCE; }
/** * Used for exception example */ @SuppressWarnings({ "unchecked", "unused" }) private void return_empty_iterator_apache_commons_exception () { DomainObject domain = null; // dao populate domain Iterator<String> strings; if (domain != null && !CollectionUtils.sizeIsEmpty(domain.getStrings())) { strings = domain.getStrings(); } else { strings = EmptyIterator.INSTANCE; } //... }
@SuppressWarnings("unchecked") public Iterator<Map<String, Object>> payloadIterator() { if ( isBatch() ) { return batch.iterator(); } if ( properties != null ) { return new SingletonListIterator( properties ); } return EmptyIterator.INSTANCE; }
public Iterator iterator() { return isEmpty() ? EmptyIterator.INSTANCE : new IteratorImpl( this ); }
public Iterator iterator() { return getHeight() == 0 ? EmptyIterator.INSTANCE : new EdgeIterator(); }
public Iterator iterator() { return getNodeSize() < 2 ? EmptyIterator.INSTANCE : new EdgeIterator(); }
@SuppressWarnings("unchecked") @Override public Iterator<RDMProperty> iterator() { return isEmpty() ? EmptyIterator.INSTANCE : rdmProperties.iterator(); }
/** * Returns an empty iterator of type <code>T</code>. * * @param <T> * @return */ @SuppressWarnings("unchecked") public static <T> Iterator<T> empty() { return EmptyIterator.INSTANCE; }