Example usage for java.util Collections emptyIterator

List of usage examples for java.util Collections emptyIterator

Introduction

In this page you can find the example usage for java.util Collections emptyIterator.

Prototype

@SuppressWarnings("unchecked")
public static <T> Iterator<T> emptyIterator() 

Source Link

Document

Returns an iterator that has no elements.

Usage

From source file:Main.java

public static Iterator getMy() {
    String nullFlag = null;// w ww  .j  a  v a 2 s . c o m
    if (nullFlag == null) {
        return Collections.emptyIterator();
    }
    return null;
}

From source file:com.yahoo.elide.jsonapi.models.SingleElementSet.java

@Override
public Iterator<T> iterator() {
    return value == null ? Collections.emptyIterator() : Collections.singleton(value).iterator();
}

From source file:Main.java

/**
 * Concatenates multiple iterables into a single iterable. The iterator exposed by the returned
 * iterable does not support {@link Iterator#remove()} even if the input iterables do.
 *
 * @throws NullPointerException if {@code iterables} or any of its elements are {@code null}
 *///w  w  w .  ja  v  a  2 s.c o  m
public static <T> Iterable<T> concat(List<Iterable<T>> iterables) {
    for (Iterable<T> iterable : iterables) {
        Objects.requireNonNull(iterable);
    }
    return new Iterable<T>() {
        @Override
        public Iterator<T> iterator() {
            if (iterables.size() == 0) {
                return Collections.emptyIterator();
            }
            return new Iterator<T>() {
                Iterator<Iterable<T>> cursor = iterables.iterator();
                Iterator<T> currentIterator = cursor.next().iterator();

                private void advance() {
                    while (!currentIterator.hasNext() && cursor.hasNext()) {
                        currentIterator = cursor.next().iterator();
                    }
                }

                @Override
                public boolean hasNext() {
                    advance();
                    return currentIterator.hasNext();
                }

                @Override
                public T next() {
                    advance();
                    return currentIterator.next();
                }
            };
        }

    };
}

From source file:cloudlens.engine.CLIterator.java

public CLIterator() {
    this.it = Collections.emptyIterator();
    this.mem = new ArrayList<>();
    this.history = new ArrayList<>();
    this.withHistory = false;
}

From source file:enmasse.broker.prestop.TopicMigrator.java

private Map<String, Host> createQueues(String address, Set<String> queues) throws Exception {
    Map<String, Host> queueMap = new LinkedHashMap<>();
    Iterator<Host> destinations = Collections.emptyIterator();
    for (String queue : queues) {
        while (!destinations.hasNext()) {
            destinations = otherHosts().iterator();
            if (destinations.hasNext()) {
                break;
            }/*from  w w w . jav a  2  s  .com*/
            Thread.sleep(1000);
        }
        Host dest = destinations.next();
        try (BrokerManager manager = new BrokerManager(dest.coreEndpoint())) {
            manager.createQueue(address, queue);
            manager.pauseQueue(queue);
        }
        queueMap.put(queue, dest);
    }
    return queueMap;
}

From source file:org.openmhealth.schema.domain.omh.SerializationUnitTests.java

@DataProvider(name = "expectedDocumentProvider")
protected Iterator<Object[]> newExpectedDocumentProvider() {

    return Collections.emptyIterator();
}

From source file:net.ontopia.topicmaps.rest.resources.AbstractPagedResource.java

protected <C> Iterator<C> page(Collection<C> collection) {

    offset = getIntegerFromQuery(Parameters.OFFSET.getName(), offset);
    limit = getIntegerFromQuery(Parameters.LIMIT.getName(), limit);

    addPagingHeaders(collection.size(), offset, limit);

    int to = offset + limit;

    // shorcuts where possible
    // todo: not possible at the moment, but we might be able to create a new
    // QueryCollection with a query that has limit and offset in it.
    //      if (collection instanceof QueryCollection) {
    //         QueryCollection qc = (QueryCollection) collection;
    //         /*from ww w.ja v a2  s .c  o m*/
    //      }

    // java optimized List.subList
    if (collection instanceof List) {
        try {
            return ((List<C>) collection).subList(offset, Math.min(collection.size(), to)).iterator();
        } catch (IndexOutOfBoundsException ioobe) {
            // offset > size
            return Collections.emptyIterator();
        }
    }

    // fallback to bounded iterator
    try {
        return IteratorUtils.boundedIterator(collection.iterator(), offset, limit);
    } catch (IllegalArgumentException iae) {
        // offset of limit negative
        return Collections.emptyIterator();
    }
}

From source file:org.openmhealth.schema.TestDataValidationIntegrationTests.java

/**
 * @return an iterator over all pairs of schema files and applicable test data files
 *//*from   w  w  w  .  j ava 2  s. c o m*/
@DataProvider(name = "validationPairProvider")
public Iterator<Object[]> newValidationPairProvider() {

    List<SchemaFile> schemaFiles = schemaFileService.getSchemaFiles(asUri(schemaFileBaseDirectory));

    if (schemaFiles.size() == 0) {
        return Collections.emptyIterator();
    }

    List<DataFile> dataFiles = dataFileService.getDataFiles(asUri(testDataFileBaseDirectory));

    if (dataFiles.size() == 0) {
        return Collections.emptyIterator();
    }

    List<Object[]> validationPairs = new ArrayList<>();

    for (SchemaFile schemaFile : schemaFiles) {

        for (DataFile dataFile : dataFiles) {

            if (!dataFile.getSchemaId().getName().equals(schemaFile.getSchemaId().getName())) {
                continue;
            }

            SchemaVersion dataFileVersion = dataFile.getSchemaId().getVersion();
            SchemaVersion schemaFileVersion = schemaFile.getSchemaId().getVersion();

            if (dataFileVersion.getMajor() != schemaFileVersion.getMajor()) {
                continue;
            }

            // a data point conforms to the schema listed in its header and newer minor versions of that schema
            if (dataFileVersion.getMinor() > schemaFileVersion.getMinor()) {
                continue;
            }

            validationPairs.add(new Object[] { schemaFile, dataFile });
        }
    }

    return validationPairs.iterator();
}

From source file:org.openmhealth.schema.domain.omh.SerializationUnitTests.java

@DataProvider(name = "expectedObjectProvider")
protected Iterator<Object[]> newExpectedObjectProvider() {

    return Collections.emptyIterator();
}

From source file:org.apache.drill.exec.store.http.HttpSubScan.java

@Override
public Iterator<PhysicalOperator> iterator() {
    return Collections.emptyIterator();
}