Class JsonArrayIterator<T>

  • All Implemented Interfaces:
    com.google.common.collect.PeekingIterator<T>, java.lang.AutoCloseable, java.util.Iterator<T>, nl.vpro.util.CloseableIterator<T>, nl.vpro.util.CountedIterator<T>

    public class JsonArrayIterator<T>
    extends com.google.common.collect.UnmodifiableIterator<T>
    implements nl.vpro.util.CloseableIterator<T>, com.google.common.collect.PeekingIterator<T>, nl.vpro.util.CountedIterator<T>
    Since:
    1.0
    Author:
    Michiel Meeuwissen
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonArrayIterator​(java.io.InputStream inputStream, java.lang.Class<T> clazz)  
      JsonArrayIterator​(java.io.InputStream inputStream, java.lang.Class<T> clazz, java.lang.Runnable callback)  
      JsonArrayIterator​(java.io.InputStream inputStream, java.util.function.BiFunction<com.fasterxml.jackson.core.JsonParser,​com.fasterxml.jackson.core.TreeNode,​T> valueCreator)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void callback()  
      void close()  
      void finalize()  
      protected void findNext()  
      java.lang.Long getCount()  
      @NonNull java.util.Optional<java.lang.Long> getSize()  
      @NonNull java.util.Optional<java.lang.Long> getTotalSize()  
      boolean hasNext()  
      T next()  
      T peek()  
      void write​(java.io.OutputStream out, java.util.function.Function<T,​java.lang.Void> logging)
      Write the entire stream to an output stream
      static <T> void write​(nl.vpro.util.CountedIterator<T> iterator, java.io.OutputStream out, java.util.function.Function<T,​java.lang.Void> logging)
      Write the entire stream to an output stream
      • Methods inherited from class com.google.common.collect.UnmodifiableIterator

        remove
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface nl.vpro.util.CloseableIterator

        stream
      • Methods inherited from interface nl.vpro.util.CountedIterator

        peeking, spliterator
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
      • Methods inherited from interface com.google.common.collect.PeekingIterator

        remove
    • Constructor Detail

      • JsonArrayIterator

        public JsonArrayIterator​(java.io.InputStream inputStream,
                                 java.lang.Class<T> clazz)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • JsonArrayIterator

        public JsonArrayIterator​(java.io.InputStream inputStream,
                                 java.lang.Class<T> clazz,
                                 java.lang.Runnable callback)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • JsonArrayIterator

        public JsonArrayIterator​(java.io.InputStream inputStream,
                                 java.util.function.BiFunction<com.fasterxml.jackson.core.JsonParser,​com.fasterxml.jackson.core.TreeNode,​T> valueCreator)
                          throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • hasNext

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

        public T peek()
        Specified by:
        peek in interface com.google.common.collect.PeekingIterator<T>
      • next

        public T next()
        Specified by:
        next in interface java.util.Iterator<T>
        Specified by:
        next in interface com.google.common.collect.PeekingIterator<T>
      • getCount

        public java.lang.Long getCount()
        Specified by:
        getCount in interface nl.vpro.util.CountedIterator<T>
      • findNext

        protected void findNext()
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface nl.vpro.util.CountedIterator<T>
        Throws:
        java.io.IOException
      • finalize

        public void finalize()
        Overrides:
        finalize in class java.lang.Object
      • callback

        protected void callback()
      • write

        public void write​(java.io.OutputStream out,
                          java.util.function.Function<T,​java.lang.Void> logging)
                   throws java.io.IOException
        Write the entire stream to an output stream
        Throws:
        java.io.IOException
      • write

        public static <T> void write​(nl.vpro.util.CountedIterator<T> iterator,
                                     java.io.OutputStream out,
                                     java.util.function.Function<T,​java.lang.Void> logging)
                              throws java.io.IOException
        Write the entire stream to an output stream
        Throws:
        java.io.IOException
      • getSize

        public @NonNull java.util.Optional<java.lang.Long> getSize()
        Specified by:
        getSize in interface nl.vpro.util.CountedIterator<T>
      • getTotalSize

        public @NonNull java.util.Optional<java.lang.Long> getTotalSize()
        Specified by:
        getTotalSize in interface nl.vpro.util.CountedIterator<T>