Java Code Examples for java.util.Collections#emptyListIterator()

The following examples show how to use java.util.Collections#emptyListIterator() . 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: LemmaSampleEventStream.java    From ixa-pipe-pos with Apache License 2.0 6 votes vote down vote up
protected Iterator<Event> createEvents(LemmaSample sample) {

    if (sample != null) {
      List<Event> events = new ArrayList<Event>();
      String[] toksArray = sample.getTokens();
      String[] tagsArray = sample.getTags();
      String[] predsArray = sample.getLemmas();
      for (int ei = 0, el = sample.getTokens().length; ei < el; ei++) {
        events.add(new Event(predsArray[ei], contextGenerator.getContext(ei,toksArray,tagsArray,predsArray)));
      }
      return events.iterator();
    }
    else {
      return Collections.emptyListIterator();
    }
  }
 
Example 2
Source File: ReturnEmptyListIterator.java    From levelup-java-examples with Apache License 2.0 6 votes vote down vote up
/**
 * Used for exception example
 */
@SuppressWarnings("unused")
private void return_empty_list_iterator_java_exception () {

	DomainObject domain = null; // dao populate domain

	ListIterator<String> strings;
	if (domain != null && domain.getStrings() != null 
			&& domain.getStrings().hasNext()) {
		strings = domain.getStrings();
	} else {
		strings = Collections.emptyListIterator();
	}
	
	//...
}
 
Example 3
Source File: MatrixBlock.java    From systemds with Apache License 2.0 5 votes vote down vote up
public Iterator<IJV> getSparseBlockIterator(int rl, int ru) {
	//check for valid format, should have been checked from outside
	if( !sparse )
		throw new RuntimeException("getSparseBlockInterator should not be called for dense format");
	
	//check for existing sparse block: return empty list
	if( sparseBlock==null )
		return Collections.emptyListIterator();
	
	//get iterator over sparse block
	return sparseBlock.getIterator(rl, ru);
}
 
Example 4
Source File: KafkaSpout.java    From storm_spring_boot_demo with MIT License 5 votes vote down vote up
@Override
    public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
        initialized = false;
        this.context = context;

        // Spout internals
        this.collector = collector;
        numUncommittedOffsets = 0;

        // Offset management
        firstPollOffsetStrategy = kafkaSpoutConfig.getFirstPollOffsetStrategy();
        // with AutoCommitMode, offset will be periodically committed in the background by Kafka consumer
//        consumerAutoCommitMode = kafkaSpoutConfig.isConsumerAutoCommitMode();
        //永远设置为false
        consumerAutoCommitMode = false;

        // Retries management
        retryService = kafkaSpoutConfig.getRetryService();

        if (!consumerAutoCommitMode) {     // If it is auto commit, no need to commit offsets manually
            commitTimer = new Timer(TIMER_DELAY_MS, kafkaSpoutConfig.getOffsetsCommitPeriodMs(), TimeUnit.MILLISECONDS);
        }
        refreshSubscriptionTimer = new Timer(TIMER_DELAY_MS, kafkaSpoutConfig.getPartitionRefreshPeriodMs(), TimeUnit.MILLISECONDS);

        acked = new HashMap<>();
        emitted = new HashSet<>();
        waitingToEmit = Collections.emptyListIterator();

        LOG.info("Kafka Spout opened with the following configuration: {}", kafkaSpoutConfig);
    }
 
Example 5
Source File: MatrixBlock.java    From systemds with Apache License 2.0 5 votes vote down vote up
public Iterator<IJV> getSparseBlockIterator(int rl, int ru) {
	//check for valid format, should have been checked from outside
	if( !sparse )
		throw new RuntimeException("getSparseBlockInterator should not be called for dense format");
	
	//check for existing sparse block: return empty list
	if( sparseBlock==null )
		return Collections.emptyListIterator();
	
	//get iterator over sparse block
	return sparseBlock.getIterator(rl, ru);
}
 
Example 6
Source File: DefaultOperationRequestAddress.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Iterator<Node> iterator() {

    if(nodes.isEmpty()) {
        return Collections.emptyListIterator();
    }

    final Node[] array = nodes.toArray(new Node[nodes.size()]);
    return new Iterator<Node>() {

        int i = 0;

        @Override
        public boolean hasNext() {
            return i < array.length;
        }

        @Override
        public Node next() {
            return array[i++];
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException();
        }

    };
}
 
Example 7
Source File: IndexMaintainer.java    From phoenix with Apache License 2.0 5 votes vote down vote up
public static void serializeServerMaintainedIndexes(PTable dataTable, ImmutableBytesWritable ptr,
        List<PTable> indexes, PhoenixConnection connection) {
    Iterator<PTable> indexesItr = Collections.emptyListIterator();
    boolean onlyLocalIndexes = dataTable.isImmutableRows() || dataTable.isTransactional();
    if (onlyLocalIndexes) {
        if (!dataTable.isTransactional()
                || !dataTable.getTransactionProvider().getTransactionProvider().isUnsupported(Feature.MAINTAIN_LOCAL_INDEX_ON_SERVER)) {
            indexesItr = maintainedLocalIndexes(indexes.iterator());
        }
    } else {
        indexesItr = maintainedIndexes(indexes.iterator());
    }

    serialize(dataTable, ptr, Lists.newArrayList(indexesItr), connection);
}
 
Example 8
Source File: ReturnEmptyListIterator.java    From levelup-java-examples with Apache License 2.0 3 votes vote down vote up
@Test
public void return_empty_list_iterator_java () {
	
	ListIterator<String> strings = Collections.emptyListIterator();

	assertFalse(strings.hasNext());
}