Package org.assertj.core.presentation
Class HeadTailAccumulator<T>
java.lang.Object
org.assertj.core.presentation.HeadTailAccumulator<T>
Accumulates the values in a stream or iterable, keeping the first and last elements and discarding everything in between.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHeadTailAccumulator
(int headCapacity, int tailCapacity) Creates a newHeadTailAccumulator
. -
Method Summary
-
Field Details
-
head
The first elements seen. -
tail
The elements seen most recently, excluding anything already onhead
.
-
-
Constructor Details
-
HeadTailAccumulator
HeadTailAccumulator(int headCapacity, int tailCapacity) Creates a newHeadTailAccumulator
.- Parameters:
headCapacity
- the maximum number of elements to retain from the start of the streamtailCapacity
- the maximum number of elements to retain from the end of the stream.- Throws:
IllegalArgumentException
- if either argument is negative
-
-
Method Details
-
add
Adds an element to the accumulator, possibly displacing an older element.- Parameters:
element
- the element to add (may benull
)
-
stream
Converts the accumulated elements into a stream.- Returns:
- the head and tail concatenated
-