-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added method withTarantoolClientConfig, withDefaultMessagePackMapperC…
…onfiguration and created interface for builder of MessagePackMapper
- Loading branch information
Showing
8 changed files
with
341 additions
and
132 deletions.
There are no files selected for viewing
136 changes: 136 additions & 0 deletions
136
src/main/java/io/tarantool/driver/api/MessagePackMapperBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package io.tarantool.driver.api; | ||
|
||
import io.tarantool.driver.mappers.MessagePackMapper; | ||
import io.tarantool.driver.mappers.ObjectConverter; | ||
import io.tarantool.driver.mappers.ValueConverter; | ||
import org.msgpack.value.Value; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Builder for {@link MessagePackMapper} | ||
*/ | ||
public interface MessagePackMapperBuilder { | ||
/** | ||
* Configure the mapper with default {@code MP_MAP} entity to {@link Map} converter | ||
* | ||
* @return builder | ||
*/ | ||
MessagePackMapperBuilder withDefaultMapValueConverter(); | ||
|
||
/** | ||
* Configure the mapper with default {@link Map} to {@code MP_MAP} entity converter | ||
* | ||
* @return builder | ||
*/ | ||
MessagePackMapperBuilder withDefaultMapObjectConverter(); | ||
|
||
/** | ||
* Configure the mapper with default {@code MP_ARRAY} entity to {@link List} converter | ||
* | ||
* @return builder | ||
*/ | ||
MessagePackMapperBuilder withDefaultArrayValueConverter(); | ||
|
||
/** | ||
* Configure the mapper with default {@link List} to {@code MP_ARRAY} entity converter | ||
* | ||
* @return builder | ||
*/ | ||
MessagePackMapperBuilder withDefaultListObjectConverter(); | ||
|
||
/** | ||
* Configure the mapper with a specified MessagePack entity-to-object and object-to-entity converter | ||
* | ||
* @param valueClass MessagePack entity class | ||
* @param objectClass object class | ||
* @param converter MessagePack entity-to-object and object-to-entity converter | ||
* @param <V> MessagePack entity type | ||
* @param <O> object type | ||
* @param <T> converter type | ||
* @return builder | ||
*/ | ||
<V extends Value, O, T extends ValueConverter<V, O> & ObjectConverter<O, V>> MessagePackMapperBuilder withConverter( | ||
Class<V> valueClass, Class<O> objectClass, T converter); | ||
|
||
/** | ||
* Configure the mapper with a specified MessagePack entity-to-object converter | ||
* | ||
* @param converter MessagePack entity-to-object and object-to-entity converter | ||
* @param <V> MessagePack entity type | ||
* @param <O> object type | ||
* @return builder | ||
* @see io.tarantool.driver.mappers.DefaultMessagePackMapper#registerValueConverter(ValueConverter) | ||
*/ | ||
<V extends Value, O> MessagePackMapperBuilder withValueConverter(ValueConverter<V, O> converter); | ||
|
||
/** | ||
* Configure the mapper with a specified MessagePack entity-to-object converter | ||
* | ||
* @param valueClass source entity class | ||
* @param converter MessagePack entity-to-object and object-to-entity converter | ||
* @param <V> MessagePack entity type | ||
* @param <O> object type | ||
* @return builder | ||
* @see io.tarantool.driver.mappers.DefaultMessagePackMapper#registerValueConverter(Class, ValueConverter) | ||
*/ | ||
<V extends Value, O> MessagePackMapperBuilder | ||
withValueConverter(Class<V> valueClass, ValueConverter<V, O> converter); | ||
|
||
/** | ||
* Configure the mapper with a specified MessagePack entity-to-object converter | ||
* | ||
* @param valueClass source entity class | ||
* @param objectClass target object class | ||
* @param converter MessagePack entity-to-object and object-to-entity converter | ||
* @param <V> MessagePack entity type | ||
* @param <O> object type | ||
* @return builder | ||
* @see io.tarantool.driver.mappers.DefaultMessagePackMapper#registerValueConverter(Class, Class, ValueConverter) | ||
*/ | ||
<V extends Value, O> MessagePackMapperBuilder withValueConverter(Class<V> valueClass, Class<O> objectClass, | ||
ValueConverter<V, O> converter); | ||
|
||
/** | ||
* Configure the mapper with a specified MessagePack object-to-entity converter | ||
* | ||
* @param converter MessagePack entity-to-object and object-to-entity converter | ||
* @param <V> MessagePack entity type | ||
* @param <O> object type | ||
* @return builder | ||
*/ | ||
<V extends Value, O> MessagePackMapperBuilder withObjectConverter(ObjectConverter<O, V> converter); | ||
|
||
/** | ||
* Configure the mapper with a specified MessagePack object-to-entity converter | ||
* | ||
* @param objectClass source object class | ||
* @param converter MessagePack entity-to-object and object-to-entity converter | ||
* @param <V> MessagePack entity type | ||
* @param <O> object type | ||
* @return builder | ||
*/ | ||
<V extends Value, O> MessagePackMapperBuilder | ||
withObjectConverter(Class<O> objectClass, ObjectConverter<O, V> converter); | ||
|
||
/** | ||
* Configure the mapper with a specified MessagePack object-to-entity converter | ||
* | ||
* @param objectClass source object class | ||
* @param valueClass target object class | ||
* @param converter MessagePack entity-to-object and object-to-entity converter | ||
* @param <V> MessagePack entity type | ||
* @param <O> object type | ||
* @return builder | ||
*/ | ||
<V extends Value, O> MessagePackMapperBuilder withObjectConverter(Class<O> objectClass, Class<V> valueClass, | ||
ObjectConverter<O, V> converter); | ||
|
||
/** | ||
* Build the mapper instance | ||
* | ||
* @return a new mapper instance | ||
*/ | ||
MessagePackMapper build(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.