Java Code Examples for org.apache.commons.collections.iterators.EmptyIterator#INSTANCE

The following examples show how to use org.apache.commons.collections.iterators.EmptyIterator#INSTANCE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlgPropertiesStep.java    From sqlg with MIT License 6 votes vote down vote up
@Override
protected Iterator<E> flatMap(final Traverser.Admin<Element> traverser) {
    for (String appliesToLabel : appliesToLabels) {
        String label = SqlgUtil.originalLabel(appliesToLabel);
        Object o = traverser.path().get(label);
        if (o instanceof List) {
            List<SqlgElement> objects = (List) o;
            SqlgElement last = objects.get(objects.size() - 1);
            if (this.returnType.equals(PropertyType.VALUE)) {
                return last.values(this.propertyKeys);
            } else {
                return (Iterator)last.properties(this.propertyKeys);
            }
        } else {
            SqlgElement sqlgElement = traverser.path().get(label);
            if (this.returnType.equals(PropertyType.VALUE)) {
                return sqlgElement.values(this.propertyKeys);
            } else {
                return (Iterator) sqlgElement.properties(this.propertyKeys);
            }
        }
    }
    return EmptyIterator.INSTANCE;
}
 
Example 2
Source File: Flat3Map.java    From Penetration_Testing_POC with Apache License 2.0 5 votes vote down vote up
public Iterator iterator() {
    if (parent.delegateMap != null) {
        return parent.delegateMap.entrySet().iterator();
    }
    if (parent.size() == 0) {
        return EmptyIterator.INSTANCE;
    }
    return new EntrySetIterator(parent);
}
 
Example 3
Source File: Flat3Map.java    From Penetration_Testing_POC with Apache License 2.0 5 votes vote down vote up
public Iterator iterator() {
    if (parent.delegateMap != null) {
        return parent.delegateMap.keySet().iterator();
    }
    if (parent.size() == 0) {
        return EmptyIterator.INSTANCE;
    }
    return new KeySetIterator(parent);
}
 
Example 4
Source File: Flat3Map.java    From Penetration_Testing_POC with Apache License 2.0 5 votes vote down vote up
public Iterator iterator() {
    if (parent.delegateMap != null) {
        return parent.delegateMap.values().iterator();
    }
    if (parent.size() == 0) {
        return EmptyIterator.INSTANCE;
    }
    return new ValuesIterator(parent);
}
 
Example 5
Source File: AbstractHashedMap.java    From Penetration_Testing_POC with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 6
Source File: AbstractHashedMap.java    From Penetration_Testing_POC with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 7
Source File: AbstractHashedMap.java    From Penetration_Testing_POC with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 8
Source File: CompositeCollection.java    From Penetration_Testing_POC with Apache License 2.0 5 votes vote down vote up
/**
 * Gets an iterator over all the collections in this composite.
 * <p>
 * This implementation uses an <code>IteratorChain</code>.
 *
 * @return an <code>IteratorChain</code> instance which supports
 *  <code>remove()</code>. Iteration occurs over contained collections in
 *  the order they were added, but this behavior should not be relied upon.
 * @see IteratorChain
 */
public Iterator iterator() {
    if (this.all.length == 0) {
        return EmptyIterator.INSTANCE;
    }
    IteratorChain chain = new IteratorChain();
    for (int i = 0; i < this.all.length; ++i) {
        chain.addIterator(this.all[i].iterator());
    }
    return chain;
}
 
Example 9
Source File: MultiHashMap.java    From Penetration_Testing_POC with Apache License 2.0 5 votes vote down vote up
/**
 * Gets an iterator for the collection mapped to the specified key.
 * 
 * @param key  the key to get an iterator for
 * @return the iterator of the collection at the key, empty iterator if key not in map
 * @since Commons Collections 3.1
 */
public Iterator iterator(Object key) {
    Collection coll = getCollection(key);
    if (coll == null) {
        return EmptyIterator.INSTANCE;
    }
    return coll.iterator();
}
 
Example 10
Source File: WithStatementScope.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
public Iterator<IModulaSymbol> iterator() {
    IRecordTypeSymbol withExpressionType = ReferenceUtils.resolve(withExpressionTypeRef);
    if (withExpressionType == null) {
        return EmptyIterator.INSTANCE;
    }
    return withExpressionType.iterator();
}
 
Example 11
Source File: ServicePayload.java    From usergrid with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public Iterator<Map<String, Object>> payloadIterator() {
    if ( isBatch() ) {
        return batch.iterator();
    }
    if ( properties != null ) {
        return new SingletonListIterator( properties );
    }
    return EmptyIterator.INSTANCE;
}
 
Example 12
Source File: ReturnEmptyIterator.java    From levelup-java-examples with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
	}
	
	//...
}