Class CountingCRLinkedList<K,​V>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<E>
java.util.LinkedList<org.apache.kafka.clients.consumer.ConsumerRecords<K,​V>>
io.confluent.parallelconsumer.CountingCRLinkedList<K,​V>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<org.apache.kafka.clients.consumer.ConsumerRecords<K,​V>>, java.util.Collection<org.apache.kafka.clients.consumer.ConsumerRecords<K,​V>>, java.util.Deque<org.apache.kafka.clients.consumer.ConsumerRecords<K,​V>>, java.util.List<org.apache.kafka.clients.consumer.ConsumerRecords<K,​V>>, java.util.Queue<org.apache.kafka.clients.consumer.ConsumerRecords<K,​V>>

public class CountingCRLinkedList<K,​V>
extends java.util.LinkedList<org.apache.kafka.clients.consumer.ConsumerRecords<K,​V>>
implements java.util.Queue<org.apache.kafka.clients.consumer.ConsumerRecords<K,​V>>
Cached view of the nested number of records in this queue.

Also protects against concurrent modification exceptions, as we don't need to traverse the list to count the nested elements. The count won't then be always exact, but it doesn't need to be.

See Also:
Serialized Form
  • Field Summary

    Fields inherited from class java.util.AbstractList

    modCount
  • Constructor Summary

    Constructors 
    Constructor Description
    CountingCRLinkedList()  
  • Method Summary

    Modifier and Type Method Description
    void add​(int index, org.apache.kafka.clients.consumer.ConsumerRecords<K,​V> element)  
    boolean add​(org.apache.kafka.clients.consumer.ConsumerRecords<K,​V> element)  
    protected boolean canEqual​(java.lang.Object other)  
    boolean equals​(java.lang.Object o)  
    int getNestedCount()
    The number of nested ConsumerRecord in this collection.
    int hashCode()  
    org.apache.kafka.clients.consumer.ConsumerRecords<K,​V> poll()  

    Methods inherited from class java.util.LinkedList

    addAll, addAll, addFirst, addLast, clear, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, pollFirst, pollLast, pop, push, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, spliterator, toArray, toArray

    Methods inherited from class java.util.AbstractSequentialList

    iterator

    Methods inherited from class java.util.AbstractList

    listIterator, removeRange, subList

    Methods inherited from class java.util.AbstractCollection

    containsAll, isEmpty, removeAll, retainAll, toString

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.util.Collection

    parallelStream, removeIf, stream, toArray

    Methods inherited from interface java.util.Deque

    iterator

    Methods inherited from interface java.lang.Iterable

    forEach

    Methods inherited from interface java.util.List

    containsAll, isEmpty, iterator, listIterator, removeAll, replaceAll, retainAll, sort, subList
  • Constructor Details

  • Method Details

    • add

      public void add​(int index, org.apache.kafka.clients.consumer.ConsumerRecords<K,​V> element)
      Specified by:
      add in interface java.util.List<K>
      Overrides:
      add in class java.util.LinkedList<org.apache.kafka.clients.consumer.ConsumerRecords<K,​V>>
    • add

      public boolean add​(org.apache.kafka.clients.consumer.ConsumerRecords<K,​V> element)
      Specified by:
      add in interface java.util.Collection<K>
      Specified by:
      add in interface java.util.Deque<K>
      Specified by:
      add in interface java.util.List<K>
      Specified by:
      add in interface java.util.Queue<K>
      Overrides:
      add in class java.util.LinkedList<org.apache.kafka.clients.consumer.ConsumerRecords<K,​V>>
    • poll

      public org.apache.kafka.clients.consumer.ConsumerRecords<K,​V> poll()
      Specified by:
      poll in interface java.util.Deque<K>
      Specified by:
      poll in interface java.util.Queue<K>
      Overrides:
      poll in class java.util.LinkedList<org.apache.kafka.clients.consumer.ConsumerRecords<K,​V>>
    • equals

      public boolean equals​(java.lang.Object o)
      Specified by:
      equals in interface java.util.Collection<K>
      Specified by:
      equals in interface java.util.List<K>
      Overrides:
      equals in class java.util.AbstractList<org.apache.kafka.clients.consumer.ConsumerRecords<K,​V>>
    • canEqual

      protected boolean canEqual​(java.lang.Object other)
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface java.util.Collection<K>
      Specified by:
      hashCode in interface java.util.List<K>
      Overrides:
      hashCode in class java.util.AbstractList<org.apache.kafka.clients.consumer.ConsumerRecords<K,​V>>
    • getNestedCount

      public int getNestedCount()
      The number of nested ConsumerRecord in this collection. As this is a non blocking collection, this won't be exact.