private BindConverter(ConversionService conversionService, Consumer<PropertyEditorRegistry> propertyEditorInitializer) { Assert.notNull(conversionService, "ConversionService must not be null"); List<ConversionService> conversionServices = getConversionServices( conversionService, propertyEditorInitializer); this.conversionService = new CompositeConversionService(conversionServices); }
@Override @SuppressWarnings("unchecked") public <T> T convert(Object source, Class<T> targetType) { Assert.notNull(targetType, "Target type to convert to cannot be null"); return (T) convert(source, TypeDescriptor.forObject(source), TypeDescriptor.valueOf(targetType)); }
@Override public boolean canConvert(Class<?> sourceType, Class<?> targetType) { Assert.notNull(targetType, "Target type to convert to cannot be null"); return canConvert( (sourceType != null) ? TypeDescriptor.valueOf(sourceType) : null, TypeDescriptor.valueOf(targetType)); }