public class LimitedDataBufferList extends ArrayList<DataBuffer>
List
to collect data buffers with and enforce a
limit on the total number of bytes buffered. For use with "collect" or
other buffering operators in declarative APIs, e.g. Flux
.
Adding elements increases the byte count and if the limit is exceeded,
DataBufferLimitException
is raised. clear()
resets the
count. Remove and set are not supported.
Note: This class does not automatically release the
buffers it contains. It is usually preferable to use hooks such as
Flux.doOnDiscard(java.lang.Class<R>, java.util.function.Consumer<? super R>)
that also take care of cancel and error signals,
or otherwise releaseAndClear()
can be used.
modCount
Constructor and Description |
---|
LimitedDataBufferList(int maxByteCount) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(DataBuffer buffer) |
void |
add(int index,
DataBuffer buffer) |
boolean |
addAll(Collection<? extends DataBuffer> collection) |
boolean |
addAll(int index,
Collection<? extends DataBuffer> collection) |
void |
clear() |
void |
releaseAndClear()
|
DataBuffer |
remove(int index) |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
removeIf(Predicate<? super DataBuffer> filter) |
protected void |
removeRange(int fromIndex,
int toIndex) |
DataBuffer |
set(int index,
DataBuffer element) |
clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, replaceAll, retainAll, size, sort, spliterator, subList, toArray, toArray, trimToSize
equals, hashCode
containsAll, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
containsAll, equals, hashCode
parallelStream, stream
public boolean add(DataBuffer buffer)
add
in interface Collection<DataBuffer>
add
in interface List<DataBuffer>
add
in class ArrayList<DataBuffer>
public void add(int index, DataBuffer buffer)
add
in interface List<DataBuffer>
add
in class ArrayList<DataBuffer>
public boolean addAll(Collection<? extends DataBuffer> collection)
addAll
in interface Collection<DataBuffer>
addAll
in interface List<DataBuffer>
addAll
in class ArrayList<DataBuffer>
public boolean addAll(int index, Collection<? extends DataBuffer> collection)
addAll
in interface List<DataBuffer>
addAll
in class ArrayList<DataBuffer>
public DataBuffer remove(int index)
remove
in interface List<DataBuffer>
remove
in class ArrayList<DataBuffer>
public boolean remove(Object o)
remove
in interface Collection<DataBuffer>
remove
in interface List<DataBuffer>
remove
in class ArrayList<DataBuffer>
protected void removeRange(int fromIndex, int toIndex)
removeRange
in class ArrayList<DataBuffer>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<DataBuffer>
removeAll
in interface List<DataBuffer>
removeAll
in class ArrayList<DataBuffer>
public boolean removeIf(Predicate<? super DataBuffer> filter)
removeIf
in interface Collection<DataBuffer>
removeIf
in class ArrayList<DataBuffer>
public DataBuffer set(int index, DataBuffer element)
set
in interface List<DataBuffer>
set
in class ArrayList<DataBuffer>
public void clear()
clear
in interface Collection<DataBuffer>
clear
in interface List<DataBuffer>
clear
in class ArrayList<DataBuffer>
public void releaseAndClear()