Top Description Fields Constructors Methods
org.assertj.core.presentation

pack-priv final Class HeadTailAccumulator<T>

extends Object
Class Inheritance
Static Imports
org.assertj.core.util.Preconditions.checkArgument

Accumulates the values in a stream or iterable, keeping the first and last elements and discarding everything in between.

Field Summary

Modifier and TypeField and Description
private final Queue<T>
head

The first elements seen.

private final Queue<T>
tail

The elements seen most recently, excluding anything already on head.

Constructor Summary

AccessConstructor and Description
pack-priv
HeadTailAccumulator(int
the maximum number of elements to retain from the start of the stream
headCapacity
,
int
the maximum number of elements to retain from the end of the stream.
tailCapacity
)

Creates a new HeadTailAccumulator.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
add(final T
the element to add (may be null)
element
)

Adds an element to the accumulator, possibly displacing an older element.

pack-priv Stream<T>

Returns:

the head and tail concatenated
stream
()

Converts the accumulated elements into a stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

tailback to summary
private final Queue<T> tail

The elements seen most recently, excluding anything already on head.

Constructor Detail

HeadTailAccumulatorback to summary
pack-priv HeadTailAccumulator(int headCapacity, int tailCapacity)

Creates a new HeadTailAccumulator.

Parameters
headCapacity:int

the maximum number of elements to retain from the start of the stream

tailCapacity:int

the maximum number of elements to retain from the end of the stream.

Exceptions
IllegalArgumentException:
if either argument is negative

Method Detail

addback to summary
pack-priv void add(final T element)

Adds an element to the accumulator, possibly displacing an older element.

Parameters
element:T

the element to add (may be null)

streamback to summary
pack-priv Stream<T> stream()

Converts the accumulated elements into a stream.

Returns:Stream<T>

the head and tail concatenated