Package org.aksw.commons.beans.model
Class ConversionServiceAdapter
java.lang.Object
org.aksw.commons.beans.model.ConversionServiceAdapter
- All Implemented Interfaces:
ConversionService
A generic adapter for ConversionService.
Allows to easily bridge to any external implementations such as those of the spring framework
as shown in the example below.
DefaultConversionService dcs = new org.springframework.core.convert.support.DefaultConversionService(); org.aksw.commons.beans.model.ConversionService cs = ConversionServiceAdapter.wrap(dcs, dcs::canConvert, dcs:convert)
- Author:
- Claus Stadler
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BiPredicate<Class<?>,Class<?>> protected ConversionServiceAdapter.ConvertFunctionprotected ObjectThe delegating object such as a spring ConversionService - should be specified but may be null -
Constructor Summary
ConstructorsConstructorDescriptionConversionServiceAdapter(Object delegate, BiPredicate<Class<?>, Class<?>> canConvert, ConversionServiceAdapter.ConvertFunction converter) -
Method Summary
Modifier and TypeMethodDescription<T> booleancanConvert(Class<?> sourceType, Class<T> targetType) <T> Tstatic ConversionServicewrap(Object delegate, BiPredicate<Class<?>, Class<?>> canConvert, ConversionServiceAdapter.ConvertFunction convert) static ConversionServicewrap(BiPredicate<Class<?>, Class<?>> canConvert, ConversionServiceAdapter.ConvertFunction convert)
-
Field Details
-
delegate
The delegating object such as a spring ConversionService - should be specified but may be null -
canConvert
-
converter
-
-
Constructor Details
-
ConversionServiceAdapter
public ConversionServiceAdapter(Object delegate, BiPredicate<Class<?>, Class<?>> canConvert, ConversionServiceAdapter.ConvertFunction converter)
-
-
Method Details
-
getDelegate
-
canConvert
- Specified by:
canConvertin interfaceConversionService
-
convert
- Specified by:
convertin interfaceConversionService
-
wrap
public static ConversionService wrap(BiPredicate<Class<?>, Class<?>> canConvert, ConversionServiceAdapter.ConvertFunction convert) -
wrap
public static ConversionService wrap(Object delegate, BiPredicate<Class<?>, Class<?>> canConvert, ConversionServiceAdapter.ConvertFunction convert)
-