Class JsonArrayIterator.Builder<T>

java.lang.Object
nl.vpro.jackson2.JsonArrayIterator.Builder<T>
Enclosing class:
JsonArrayIterator<T>

public static class JsonArrayIterator.Builder<T> extends Object
  • Method Details

    • inputStream

      public JsonArrayIterator.Builder<T> inputStream(@NonNull InputStream inputStream)
      Parameters:
      inputStream - The inputstream containing the json
      Returns:
      this.
    • valueCreator

      public JsonArrayIterator.Builder<T> valueCreator(@Nullable BiFunction<com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.core.TreeNode,T> valueCreator)
      Parameters:
      valueCreator - A function which converts a json TreeNode to the desired objects in the iterator.
      Returns:
      this.
    • valueClass

      public JsonArrayIterator.Builder<T> valueClass(@Nullable Class<T> valueClass)
      Parameters:
      valueClass - If valueCreator is not given, simply the class of the desired object can be given Json unmarshalling with the given objectMapper will happen.
      Returns:
      this.
    • callback

      public JsonArrayIterator.Builder<T> callback(@Nullable Runnable callback)
      Parameters:
      callback - If the iterator is ready, closed or error this callback will be called.
      Returns:
      this.
    • sizeField

      public JsonArrayIterator.Builder<T> sizeField(@Nullable String sizeField)
      Parameters:
      sizeField - The size of the iterator, i.e. the size of the array represented in the json stream
      Returns:
      this.
    • totalSizeField

      public JsonArrayIterator.Builder<T> totalSizeField(@Nullable String totalSizeField)
      Parameters:
      totalSizeField - Sometimes the array is part of something bigger, e.g. a page in a search result. The size of the 'complete' result can be in the beginning of the json in this field.
      Returns:
      this.
    • objectMapper

      public JsonArrayIterator.Builder<T> objectMapper(@Nullable com.fasterxml.jackson.databind.ObjectMapper objectMapper)
      Parameters:
      objectMapper - Default the objectMapper Jackson2Mapper.getLenientInstance() will be used (in conjunction with valueClass, but you may specify another one
      Returns:
      this.
    • logger

      public JsonArrayIterator.Builder<T> logger(@Nullable org.slf4j.Logger logger)
      Parameters:
      logger - Default this is logging to nl.vpro.jackson2.JsonArrayIterator, but you may override that.
      Returns:
      this.
    • skipNulls

      public JsonArrayIterator.Builder<T> skipNulls(@Nullable Boolean skipNulls)
      Parameters:
      skipNulls - Whether to skip nulls in the array. Default true.
      Returns:
      this.
    • eventListener

      public JsonArrayIterator.Builder<T> eventListener(@Nullable JsonArrayIterator.Listener<T> eventListener)
      Parameters:
      eventListener - A listener for events that happen during parsing and iteration of the array. See Event and extension classes.
      Returns:
      this.
    • build

      public JsonArrayIterator<T> build() throws IOException
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object