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 convertsMethodExecutionInfoto aString.apply(MethodExecutionInfo executionInfo) format(MethodExecutionInfo executionInfo) Convert the givenMethodExecutionInfotoStringusing registered consumers.static MethodExecutionInfoFormatterCreate aMethodExecutionInfoFormatterwith default consumers that format theMethodExecutionInfo.
-
Constructor Details
-
MethodExecutionInfoFormatter
public MethodExecutionInfoFormatter()
-
-
Method Details
-
withDefault
Create aMethodExecutionInfoFormatterwith default consumers that format theMethodExecutionInfo.- Returns:
- a formatter
-
apply
- Specified by:
applyin interfaceFunction<MethodExecutionInfo, String>
-
format
Convert the givenMethodExecutionInfotoStringusing registered consumers.- Parameters:
executionInfo- input- Returns:
- formatted sting
- Throws:
IllegalArgumentException- ifexecutionInfoisnull
-
addConsumer
public MethodExecutionInfoFormatter addConsumer(BiConsumer<MethodExecutionInfo, StringBuilder> consumer) Register a consumer that convertsMethodExecutionInfoto aString.- Parameters:
consumer- aBiConsumerthat takes aMethodExecutionInfoand write to theStringBuilder.- Returns:
- this formatter
- Throws:
IllegalArgumentException- ifconsumerisnull
-