Package nl.vpro.jackson2
Class JsonArrayIterator.Builder<T>
java.lang.Object
nl.vpro.jackson2.JsonArrayIterator.Builder<T>
- Enclosing class:
- JsonArrayIterator<T>
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
eventListener
(@Nullable JsonArrayIterator.Listener<T> eventListener) inputStream
(@NonNull InputStream inputStream) logger
(@Nullable org.slf4j.Logger logger) objectMapper
(@Nullable com.fasterxml.jackson.databind.ObjectMapper objectMapper) toString()
totalSizeField
(@Nullable String totalSizeField) valueClass
(@Nullable Class<T> valueClass) valueCreator
(@Nullable BiFunction<com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.core.TreeNode, T> valueCreator)
-
Method Details
-
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 jsonTreeNode
to the desired objects in the iterator.- Returns:
this
.
-
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
- Parameters:
callback
- If the iterator is ready, closed or error this callback will be called.- Returns:
this
.
-
sizeField
- Parameters:
sizeField
- The size of the iterator, i.e. the size of the array represented in the json stream- Returns:
this
.
-
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 objectMapperJackson2Mapper.getLenientInstance()
will be used (in conjunction withvalueClass
, but you may specify another one- Returns:
this
.
-
logger
- Parameters:
logger
- Default this is logging to nl.vpro.jackson2.JsonArrayIterator, but you may override that.- Returns:
this
.
-
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. SeeEvent
and extension classes.- Returns:
this
.
-
build
- Throws:
IOException
-
toString
-