FluxUtil Class
- java.
lang. Object - com.
azure. core. util. FluxUtil
- com.
public final class FluxUtil
Utility type exposing methods to deal with Flux.
Modifier and Type | Method and Description |
---|---|
static
Flux<Byte |
add Adds progress reporting to the provided Flux of ByteBuffer. |
static byte[] |
byte Gets the content of the provided Byte |
static Mono<byte[]> |
collect Collects Byte |
static Mono<byte[]> |
collect Collects Byte |
static Mono<byte[]> |
collect Collects Byte |
static
Flux<Byte |
create Creates a Flux that is capable of resuming a download by applying retry logic when an error occurs. |
static
Flux<Byte |
create Creates a Flux that is capable of resuming a download by applying retry logic when an error occurs. |
static
Flux<Byte |
create Creates a Flux that is capable of resuming a download by applying retry logic when an error occurs. |
static Flux<T> |
flux This method converts the incoming |
static Flux<T> |
flux Propagates a RuntimeException through the error channel of Flux. |
static boolean |
is Checks if a type is Flux<Byte |
static Mono<T> |
mono Propagates a RuntimeException through the error channel of Mono. |
static Mono<T> |
mono Propagates a RuntimeException through the error channel of Mono. |
static
Paged |
paged Propagates a RuntimeException through the error channel of PagedFlux<T>. |
static
Flux<Byte |
read Creates a Flux from an AsynchronousFileChannel which reads the entire file. |
static
Flux<Byte |
read Creates a Flux from an AsynchronousFileChannel which reads part of a file into chunks of the given size. |
static
Flux<Byte |
read Creates a Flux from an AsynchronousFileChannel which reads part of a file. |
static
Flux<Byte |
to Converts an InputStream into a Flux of ByteBuffer using a chunk size of 4096. |
static
Flux<Byte |
to Converts an InputStream into a Flux of ByteBuffer. |
static Mono<T> |
to Converts the incoming content to Mono. |
static Context |
to Converts an Azure context to Reactor context. |
static Mono<T> |
with This method converts the incoming |
static Mono<T> |
with This method converts the incoming |
static Mono<Void> |
write Writes the ByteBuffers emitted by a Flux of ByteBuffer to an AsynchronousFileChannel. |
static Mono<Void> |
write Writes the ByteBuffers emitted by a Flux of ByteBuffer to an AsynchronousFileChannel starting at the given |
static Mono<Void> |
write Writes the ByteBuffers emitted by a Flux of ByteBuffer to an AsynchronousByteChannel. |
static Mono<Void> |
write Writes the ByteBuffers emitted by a Flux of ByteBuffer to an OutputStream. |
static Mono<Void> |
write Writes the ByteBuffers emitted by a Flux of ByteBuffer to an WritableByteChannel. |
Methods inherited from java.lang.Object
addProgressReporting
public static Flux
Adds progress reporting to the provided Flux of ByteBuffer.
Each ByteBuffer that's emitted from the Flux will report ByteBuffer#remaining().
When Flux is resubscribed the progress is reset. If the flux is not replayable, resubscribing can result in empty or partial data then progress reporting might not be accurate.
If ProgressReporter is not provided, i.e. is null
, then this method returns unmodified Flux.
Parameters:
Returns:
byteBufferToArray
public static byte[] byteBufferToArray(ByteBuffer byteBuffer)
Gets the content of the provided ByteBuffer as a byte array. This method will create a new byte array even if the ByteBuffer can have optionally backing array.
Parameters:
Returns:
collectBytesFromNetworkResponse
public static Mono
Collects ByteBuffers returned in a network response into a byte array.
The headers
are inspected for containing an Content-Length
which determines if a size hinted collection, collectBytesInByteBufferStream(Flux<ByteBuffer> stream, int sizeHint), or default collection, collectBytesInByteBufferStream(Flux<ByteBuffer> stream), will be used.
Parameters:
Returns:
collectBytesInByteBufferStream
public static Mono
Collects ByteBuffers emitted by a Flux into a byte array.
Parameters:
Returns:
collectBytesInByteBufferStream
public static Mono
Collects ByteBuffers emitted by a Flux into a byte array.
Unlike collectBytesInByteBufferStream(Flux<ByteBuffer> stream), this method accepts a second parameter sizeHint
. This size hint allows for optimizations when creating the initial buffer to reduce the number of times it needs to be resized while concatenating emitted ByteBuffers.
Parameters:
Returns:
createRetriableDownloadFlux
public static Flux
Creates a Flux that is capable of resuming a download by applying retry logic when an error occurs.
Parameters:
Returns:
createRetriableDownloadFlux
public static Flux
Creates a Flux that is capable of resuming a download by applying retry logic when an error occurs.
Parameters:
Returns:
createRetriableDownloadFlux
public static Flux
Creates a Flux that is capable of resuming a download by applying retry logic when an error occurs.
Parameters:
Returns:
fluxContext
public static Flux
This method converts the incoming deferContextual
from Reactor
Context to Azure Context and calls the given lambda function with this context and returns a collection of type T
If the reactor context is empty, NONE will be used to call the lambda function
Code samples
String prefix = "Hello, ";
Flux<String> response = FluxUtil
.fluxContext(context -> serviceCallReturnsCollection(prefix, context));
Parameters:
Returns:
fluxError
public static Flux
Propagates a RuntimeException through the error channel of Flux.
Parameters:
Returns:
isFluxByteBuffer
public static boolean isFluxByteBuffer(Type entityType)
Checks if a type is Flux.
Parameters:
Returns:
monoError
public static Mono
Propagates a RuntimeException through the error channel of Mono.
Parameters:
Returns:
monoError
public static Mono
Propagates a RuntimeException through the error channel of Mono.
Parameters:
Returns:
pagedFluxError
public static PagedFlux
Propagates a RuntimeException through the error channel of PagedFlux<T>.
Parameters:
Returns:
readFile
public static Flux
Creates a Flux from an AsynchronousFileChannel which reads the entire file.
Parameters:
Returns:
readFile
public static Flux
Creates a Flux from an AsynchronousFileChannel which reads part of a file into chunks of the given size.
Parameters:
Returns:
readFile
public static Flux
Creates a Flux from an AsynchronousFileChannel which reads part of a file.
Parameters:
Returns:
toFluxByteBuffer
public static Flux
Converts an InputStream into a Flux of ByteBuffer using a chunk size of 4096.
Given that InputStream is not guaranteed to be replayable the returned Flux should be considered non-replayable as well.
If the passed InputStream is null
Flux#empty() will be returned.
Parameters:
Returns:
toFluxByteBuffer
public static Flux
Converts an InputStream into a Flux of ByteBuffer.
Given that InputStream is not guaranteed to be replayable the returned Flux should be considered non-replayable as well.
If the passed InputStream is null
Flux#empty() will be returned.
Parameters:
Returns:
toMono
public static Mono
Converts the incoming content to Mono.
Parameters:
Returns:
toReactorContext
public static Context toReactorContext(Context context)
Converts an Azure context to Reactor context. If the Azure context is null
or empty, Context#empty() will be returned.
Parameters:
Returns:
withContext
public static Mono
This method converts the incoming deferContextual
from Reactor
Context to Azure Context and calls the given lambda function with this context and returns a single entity of type T
If the reactor context is empty, NONE will be used to call the lambda function
Code samples
String prefix = "Hello, ";
Mono<String> response = FluxUtil
.withContext(context -> serviceCallReturnsSingle(prefix, context));
Parameters:
Returns:
withContext
public static Mono
This method converts the incoming deferContextual
from Reactor
Context to Azure Context, adds the specified context attributes and calls the given lambda function with this context and returns a single entity of type T
If the reactor context is empty, NONE will be used to call the lambda function
Parameters:
Returns:
writeFile
public static Mono
Writes the ByteBuffers emitted by a Flux of ByteBuffer to an AsynchronousFileChannel.
The outFile
is not closed by this call, closing of the outFile
is managed by the caller.
The response Mono will emit an error if content
or outFile
are null. Additionally, an error will be emitted if the outFile
wasn't opened with the proper open options, such as StandardOpenOption#WRITE.
Parameters:
Returns:
writeFile
public static Mono
Writes the ByteBuffers emitted by a Flux of ByteBuffer to an AsynchronousFileChannel starting at the given position
in the file.
The outFile
is not closed by this call, closing of the outFile
is managed by the caller.
The response Mono will emit an error if content
or outFile
are null or position
is less than 0. Additionally, an error will be emitted if the outFile
wasn't opened with the proper open options, such as StandardOpenOption#WRITE.
Parameters:
content
.
Returns:
writeToAsynchronousByteChannel
public static Mono
Writes the ByteBuffers emitted by a Flux of ByteBuffer to an AsynchronousByteChannel.
The channel
is not closed by this call, closing of the channel
is managed by the caller.
The response Mono will emit an error if content
or channel
are null.
Parameters:
Returns:
writeToOutputStream
public static Mono
Writes the ByteBuffers emitted by a Flux of ByteBuffer to an OutputStream.
The stream
is not closed by this call, closing of the stream
is managed by the caller.
The response Mono will emit an error if content
or stream
are null. Additionally, an error will be emitted if an exception occurs while writing the content
to the stream
.
Parameters:
Returns:
writeToWritableByteChannel
public static Mono
Writes the ByteBuffers emitted by a Flux of ByteBuffer to an WritableByteChannel.
The channel
is not closed by this call, closing of the channel
is managed by the caller.
The response Mono will emit an error if content
or channel
are null.
Parameters:
Returns:
Azure SDK for Java feedback
Azure SDK for Java is an open source project. Select a link to provide feedback: