Class Chunk<W>
java.lang.Object
org.springframework.batch.infrastructure.item.Chunk<W>
- All Implemented Interfaces:
Serializable,Iterable<W>
Encapsulation of a list of items to be processed and possibly a list of failed items to
be skipped. To mark an item as skipped, clients should iterate over the chunk using the
iterator() method, and if there is a failure call
Chunk.ChunkIterator.remove() on the iterator. The skipped items are then
available through the chunk.- Since:
- 2.0
- Author:
- Dave Syer, Mahmoud Ben Hassine, Jinwoo Bae, Stefano Cordio
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassSpecial iterator for a chunk providing theChunk.ChunkIterator.remove(Throwable)method for dynamically removing an item and adding it to the skips. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd the item to the chunk.voidAdd all items to the chunk.voidclear()Clear the items down to signal that we are done.voidDeprecated, for removal: This API element is subject to removal in a future version.booleanDeprecated, for removal: This API element is subject to removal in a future version.getItems()List<SkipWrapper<W>>getSkips()Deprecated, for removal: This API element is subject to removal in a future version.intDeprecated, for removal: This API element is subject to removal in a future version.@Nullable ObjectDeprecated, for removal: This API element is subject to removal in a future version.inthashCode()booleanisBusy()Deprecated, for removal: This API element is subject to removal in a future version.booleanisEmpty()booleanisEnd()Deprecated, for removal: This API element is subject to removal in a future version.iterator()Get an unmodifiable iterator for the underlying items.static <W> Chunk<W>of(W... items) voidsetBusy(boolean busy) Deprecated, for removal: This API element is subject to removal in a future version.voidsetEnd()Deprecated, for removal: This API element is subject to removal in a future version.voidsetUserData(Object userData) Deprecated, for removal: This API element is subject to removal in a future version.intsize()voidDeprecated, for removal: This API element is subject to removal in a future version.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Chunk
-
Chunk
-
Chunk
@Deprecated(since="6.0", forRemoval=true) public Chunk(@Nullable List<? extends W> items, @Nullable List<SkipWrapper<W>> skips) Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Method Details
-
of
-
add
Add the item to the chunk.- Parameters:
item- the item to add
-
addAll
Add all items to the chunk.- Parameters:
items- the items to add
-
clear
public void clear()Clear the items down to signal that we are done. -
getItems
- Returns:
- a copy of the items to be processed as an unmodifiable list
-
getSkips
Deprecated, for removal: This API element is subject to removal in a future version.- Returns:
- a copy of the skips as an unmodifiable list
-
getErrors
Deprecated, for removal: This API element is subject to removal in a future version.- Returns:
- a copy of the anonymous errors as an unmodifiable list
-
skip
Deprecated, for removal: This API element is subject to removal in a future version.Register an anonymous skip. To skip an individual item, useChunk.ChunkIterator.remove().- Parameters:
e- the exception that caused the skip
-
isEmpty
public boolean isEmpty()- Returns:
trueif there are no items in the chunk
-
iterator
Get an unmodifiable iterator for the underlying items. -
size
public int size()- Returns:
- the number of items (excluding skips)
-
getSkipsSize
Deprecated, for removal: This API element is subject to removal in a future version.- Returns:
- the number of skipped items
-
isEnd
Deprecated, for removal: This API element is subject to removal in a future version.Flag to indicate if the source data is exhausted.Note: This may return false if the last chunk has the same number of items as the configured commit interval. Consequently, in such cases,there will be a last empty chunk that won't be processed. It is recommended to consider this behavior when utilizing this method.
- Returns:
- true if there is no more data to process
-
setEnd
Deprecated, for removal: This API element is subject to removal in a future version.Set the flag to say that this chunk represents an end of stream (there is no more data to process). -
isBusy
Deprecated, for removal: This API element is subject to removal in a future version.Query the chunk to see if anyone has registered an interest in keeping a reference to it.- Returns:
- the busy flag
-
setBusy
Deprecated, for removal: This API element is subject to removal in a future version.Register an interest in the chunk to prevent it from being cleaned up before the flag is reset to false.- Parameters:
busy- the flag to set
-
clearSkips
Deprecated, for removal: This API element is subject to removal in a future version.Clear only the skips list. -
getUserData
Deprecated, for removal: This API element is subject to removal in a future version. -
setUserData
Deprecated, for removal: This API element is subject to removal in a future version. -
toString
-
equals
-
hashCode
public int hashCode()
-