Class LoopingResumingIterator<KEY,​VALUE>

java.lang.Object
io.confluent.csid.utils.LoopingResumingIterator<KEY,​VALUE>
All Implemented Interfaces:
java.lang.Iterable<java.util.Map.Entry<KEY,​VALUE>>, java.util.Iterator<java.util.Map.Entry<KEY,​VALUE>>

public class LoopingResumingIterator<KEY,​VALUE>
extends java.lang.Object
implements java.util.Iterator<java.util.Map.Entry<KEY,​VALUE>>, java.lang.Iterable<java.util.Map.Entry<KEY,​VALUE>>
Loop implementations that will resume from a given key. Can be constructed and used as an iterable, or a function passed into the static version iterateStartingFromKeyLooping(java.util.Optional<KEY>, java.util.LinkedHashMap<KEY, VALUE>, java.util.function.Consumer<java.util.Map.Entry<KEY, VALUE>>).

The non functional version is useful when you want to use looping constructs such as break and continue.

  • Constructor Summary

    Constructors 
    Constructor Description
    LoopingResumingIterator​(java.util.Map<KEY,​VALUE> map)  
    LoopingResumingIterator​(java.util.Optional<KEY> startingKey, java.util.Map<KEY,​VALUE> map)
    Will resume from the startingKey, if it's present
  • Method Summary

    Modifier and Type Method Description
    static <KKEY,​ VVALUE>
    LoopingResumingIterator<KKEY,​VVALUE>
    build​(KKEY startingKey, java.util.Map<KKEY,​VVALUE> map)  
    java.util.Optional<KEY> getIterationStartingPoint()  
    boolean hasNext()  
    java.util.Iterator<java.util.Map.Entry<KEY,​VALUE>> iterator()  
    java.util.Map.Entry<KEY,​VALUE> next()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator

    Methods inherited from interface java.util.Iterator

    forEachRemaining, remove
  • Constructor Details

  • Method Details

    • build

      public static <KKEY,​ VVALUE> LoopingResumingIterator<KKEY,​VVALUE> build​(KKEY startingKey, java.util.Map<KKEY,​VVALUE> map)
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface java.util.Iterator<KEY>
    • next

      public java.util.Map.Entry<KEY,​VALUE> next()
      Specified by:
      next in interface java.util.Iterator<KEY>
    • iterator

      public java.util.Iterator<java.util.Map.Entry<KEY,​VALUE>> iterator()
      Specified by:
      iterator in interface java.lang.Iterable<KEY>
    • getIterationStartingPoint

      public java.util.Optional<KEY> getIterationStartingPoint()