Class LimitedDataBufferList
- java.lang.Object
- java.util.AbstractCollection<E>
- java.util.AbstractList<E>
- java.util.ArrayList<DataBuffer>
- org.springframework.core.io.buffer.LimitedDataBufferList
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<DataBuffer>
,Collection<DataBuffer>
,List<DataBuffer>
,RandomAccess
public class LimitedDataBufferList extends ArrayList<DataBuffer>
CustomList
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 otherwisereleaseAndClear()
can be used.- Since:
- 5.1.11
- Author:
- Rossen Stoyanchev
- See Also:
- Serialized Form
Field Summary
Fields inherited from class java.util.AbstractList
modCount
Constructor Summary
Constructors Constructor Description LimitedDataBufferList(int maxByteCount)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, DataBuffer buffer)
boolean
add(DataBuffer buffer)
boolean
addAll(int index, Collection<? extends DataBuffer> collection)
boolean
addAll(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)
Methods inherited from class java.util.ArrayList
clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, replaceAll, retainAll, size, sort, spliterator, subList, toArray, toArray, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods inherited from interface java.util.List
containsAll
Constructor Detail
LimitedDataBufferList
public LimitedDataBufferList(int maxByteCount)
Method Detail
add
public boolean add(DataBuffer buffer)
- Specified by:
add
in interfaceCollection<DataBuffer>
- Specified by:
add
in interfaceList<DataBuffer>
- Overrides:
add
in classArrayList<DataBuffer>
add
public void add(int index, DataBuffer buffer)
- Specified by:
add
in interfaceList<DataBuffer>
- Overrides:
add
in classArrayList<DataBuffer>
addAll
public boolean addAll(Collection<? extends DataBuffer> collection)
- Specified by:
addAll
in interfaceCollection<DataBuffer>
- Specified by:
addAll
in interfaceList<DataBuffer>
- Overrides:
addAll
in classArrayList<DataBuffer>
addAll
public boolean addAll(int index, Collection<? extends DataBuffer> collection)
- Specified by:
addAll
in interfaceList<DataBuffer>
- Overrides:
addAll
in classArrayList<DataBuffer>
remove
public DataBuffer remove(int index)
- Specified by:
remove
in interfaceList<DataBuffer>
- Overrides:
remove
in classArrayList<DataBuffer>
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<DataBuffer>
- Specified by:
remove
in interfaceList<DataBuffer>
- Overrides:
remove
in classArrayList<DataBuffer>
removeRange
protected void removeRange(int fromIndex, int toIndex)
- Overrides:
removeRange
in classArrayList<DataBuffer>
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll
in interfaceCollection<DataBuffer>
- Specified by:
removeAll
in interfaceList<DataBuffer>
- Overrides:
removeAll
in classArrayList<DataBuffer>
removeIf
public boolean removeIf(Predicate<? super DataBuffer> filter)
- Specified by:
removeIf
in interfaceCollection<DataBuffer>
- Overrides:
removeIf
in classArrayList<DataBuffer>
set
public DataBuffer set(int index, DataBuffer element)
- Specified by:
set
in interfaceList<DataBuffer>
- Overrides:
set
in classArrayList<DataBuffer>
clear
public void clear()
- Specified by:
clear
in interfaceCollection<DataBuffer>
- Specified by:
clear
in interfaceList<DataBuffer>
- Overrides:
clear
in classArrayList<DataBuffer>
releaseAndClear
public void releaseAndClear()