Class MethodExecutionInfoFormatter
java.lang.Object
io.r2dbc.proxy.support.MethodExecutionInfoFormatter
- All Implemented Interfaces:
Function<MethodExecutionInfo, String>
public class MethodExecutionInfoFormatter
extends Object
implements Function<MethodExecutionInfo, String>
Convert
MethodExecutionInfo
to String
.
Sample usage:
MethodExecutionInfoFormatter formatter = MethodExecutionInfoFormatter.withDefault();
ProxyConnectionFactory.builder(connectionFactory)
.onAfterMethod(execInfo ->
execInfo.map(methodExecutionFormatter::format) // convert
.doOnNext(System.out::println) // print out to sysout
.subscribe())
.create();
- Author:
- Tadaya Tsuyukubo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddConsumer
(BiConsumer<MethodExecutionInfo, StringBuilder> consumer) Register a consumer that convertsMethodExecutionInfo
to aString
.apply
(MethodExecutionInfo executionInfo) format
(MethodExecutionInfo executionInfo) Convert the givenMethodExecutionInfo
toString
using registered consumers.static MethodExecutionInfoFormatter
Create aMethodExecutionInfoFormatter
with default consumers that format theMethodExecutionInfo
.
-
Constructor Details
-
MethodExecutionInfoFormatter
public MethodExecutionInfoFormatter()
-
-
Method Details
-
withDefault
Create aMethodExecutionInfoFormatter
with default consumers that format theMethodExecutionInfo
.- Returns:
- a formatter
-
apply
- Specified by:
apply
in interfaceFunction<MethodExecutionInfo, String>
-
format
Convert the givenMethodExecutionInfo
toString
using registered consumers.- Parameters:
executionInfo
- input- Returns:
- formatted sting
- Throws:
IllegalArgumentException
- ifexecutionInfo
isnull
-
addConsumer
public MethodExecutionInfoFormatter addConsumer(BiConsumer<MethodExecutionInfo, StringBuilder> consumer) Register a consumer that convertsMethodExecutionInfo
to aString
.- Parameters:
consumer
- aBiConsumer
that takes aMethodExecutionInfo
and write to theStringBuilder
.- Returns:
- this formatter
- Throws:
IllegalArgumentException
- ifconsumer
isnull
-