Add ability to use different converters via factory#359
Conversation
7c8c7cf to
372f921
Compare
There was a problem hiding this comment.
I like the idea in general. Let's correct the API a bit and add some short examples in the Javadocs for the people to be able to use it and read this code.
We will need to explain what that hierarchy of mappers represents actually, how it is mapped to a real result from the server.
| */ | ||
| <T> ArrayValueToTarantoolResultMapperFactory<T> rowsMetadataStructureResultMapperFactory(); | ||
|
|
||
| Builder createMapper(); |
There was a problem hiding this comment.
Javadoc is missing. I suggest putting short builder usage example in the Javadoc
src/main/java/io/tarantool/driver/mappers/factories/ResultMapperFactoryFactory.java
Show resolved
Hide resolved
| } | ||
|
|
||
| public MessagePackValueMapper buildMessagePackMapper(MessagePackValueMapper valueMapper) { | ||
| return new CallResultMapper(valueMapper, mappers); |
There was a problem hiding this comment.
Looks like a copy-paste, should it be a DefaultMessagePackMapper?
| client.getResultMapperFactoryFactory(); | ||
| CallResultMapper callReturnMapper = factory.createMapper() | ||
| .withSingleValueConverter( | ||
| factory.createMapper() |
There was a problem hiding this comment.
In this example, we have valueMapper passed 3 times and one time with a necessary copy() call. We will never have a chance to explain how to use this to the customers, and we will make mistakes ourselves.
But let's pass the valueMapper once to the builder:
CallResultMapper callReturnMapper = factory.createMapper(valueMapper)
.withSingleValueConverter(
factory.createMapper(valueMapper)
.withArrayValueToTarantoolTupleResultConverter()
.withRowsMetadataToTarantoolTupleResultMapper()
.buildMessagePackMapper()
)
.buildCallResultMapper();
The copy() method will be called internally where it is needed.
We can make a second createMapper() method accepting also space metadata. Passing null several times is also not comfortable.
What do you think?
There was a problem hiding this comment.
Yeah, your're right. It should be more easier. I changed
Co-authored-by: Alexey Kuzin <akudiyar@gmail.com>
To use mappers for custom behavior
I haven't forgotten about:
Related issues:
Closes #320