Package io.pravega.common.util
Class BufferViewBuilder
- java.lang.Object
-
- io.pravega.common.util.BufferViewBuilder
-
@NotThreadSafe public class BufferViewBuilder extends java.lang.ObjectBuilder forBufferViewinstances.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BufferViewBuilderadd(@NonNull BufferView bufferView)Includes the givenBufferViewin the builder.BufferViewbuild()Generates aBufferViewwith the current contents of thisBufferViewBuilderinstance.intgetLength()The length, in bytes, of the accumulatedBufferView.
-
-
-
Method Detail
-
add
public BufferViewBuilder add(@NonNull @NonNull BufferView bufferView)
Includes the givenBufferViewin the builder.- Parameters:
bufferView- TheBufferViewto include. If empty, it will be ignored; if aCompositeBufferView, its components will be added; otherwise the buffer itself will be added. No data copies are being made as part of this process; the resultingBufferViewafter invokingbuild()will contain references to theBufferViews passed via this method and not contain copies of their data. Any modifications made to thisBufferViewwill be reflected in the resultingBufferViewand viceversa.- Returns:
- This instance.
-
build
public BufferView build()
Generates aBufferViewwith the current contents of thisBufferViewBuilderinstance.- Returns:
- A
BufferView. IfgetLength()is 0, returnsBufferView.empty(); otherwise returns either aCompositeBufferView(if the number of components is greater than 1), or the singleBufferViewthat it contains (if the number of components equals 1).
-
getLength
public int getLength()
The length, in bytes, of the accumulatedBufferView.
-
-