Package org.dalesbred.conversion
Interface TypeConversionRegistry
public interface TypeConversionRegistry
Registry containing the type-conversions used when converting database values
to model values and vice versa.
-
Method Summary
Modifier and TypeMethodDescription<S,
T> void registerConversionFromDatabase
(@NotNull Class<S> source, @NotNull Class<T> target, @NotNull Function<S, T> conversion) Registers conversion from given source database type to given target model type.default <D,
J> void registerConversions
(@NotNull Class<D> databaseType, @NotNull Class<J> javaType, @NotNull Function<D, J> fromDatabase, @NotNull Function<J, D> toDatabase) Registers conversions from database type to model type and back.<T> void
registerConversionToDatabase
(@NotNull Class<T> source, @NotNull Function<T, ?> conversion) Registers conversion from given source model type to database type.<T extends Enum<T>,
K>
voidregisterEnumConversion
(@NotNull Class<T> enumType, @NotNull Function<T, K> keyFunction) Registers simple enum conversion that uses keyFunction to produce saved value and uses same function on enum constants to convert values back.default <T extends Enum<T>>
voidregisterNativeEnumConversion
(@NotNull Class<T> enumType, @NotNull String typeName) Returns given enum-type to be saved as database native enum of given type name.<T extends Enum<T>,
K>
voidregisterNativeEnumConversion
(@NotNull Class<T> enumType, @NotNull String typeName, @NotNull Function<T, K> keyFunction) Returns given enum-type to be saved as database native enum of given type name.
-
Method Details
-
registerConversionFromDatabase
<S,T> void registerConversionFromDatabase(@NotNull @NotNull Class<S> source, @NotNull @NotNull Class<T> target, @NotNull @NotNull Function<S, T> conversion) Registers conversion from given source database type to given target model type. -
registerConversionToDatabase
<T> void registerConversionToDatabase(@NotNull @NotNull Class<T> source, @NotNull @NotNull Function<T, ?> conversion) Registers conversion from given source model type to database type. -
registerConversions
default <D,J> void registerConversions(@NotNull @NotNull Class<D> databaseType, @NotNull @NotNull Class<J> javaType, @NotNull @NotNull Function<D, J> fromDatabase, @NotNull @NotNull Function<J, D> toDatabase) Registers conversions from database type to model type and back. -
registerEnumConversion
<T extends Enum<T>,K> void registerEnumConversion(@NotNull @NotNull Class<T> enumType, @NotNull @NotNull Function<T, K> keyFunction) Registers simple enum conversion that uses keyFunction to produce saved value and uses same function on enum constants to convert values back. -
registerNativeEnumConversion
default <T extends Enum<T>> void registerNativeEnumConversion(@NotNull @NotNull Class<T> enumType, @NotNull @NotNull String typeName) Returns given enum-type to be saved as database native enum of given type name. -
registerNativeEnumConversion
<T extends Enum<T>,K> void registerNativeEnumConversion(@NotNull @NotNull Class<T> enumType, @NotNull @NotNull String typeName, @NotNull @NotNull Function<T, K> keyFunction) Returns given enum-type to be saved as database native enum of given type name. Given function can be used to map the enum to the stored value.
-