@Test void convertWhenNoConverterAvailable() { assertThrows(ConversionException.class, () -> this.converter.convert(ConvertUtilsConverter.class, ""), "Failed to find a Converter to convert from [java.lang.String] to " + "[" + ConvertUtilsConverter.class.getName() + "]"); }
private <T> T convert(Class<T> targetType, Object sourceValue) { T result; try { result = (T) ConvertUtils.convert(sourceValue, targetType); } catch (ConversionException ex) { throw new org.xwiki.properties.converter.ConversionException("Error while performing type conversion", ex); } if (result == null) { return null; } if (!TypeUtils.isAssignable(targetType, result.getClass())) { throw new org.xwiki.properties.converter.ConversionException( String.format("Failed to find a Converter to convert from [%s] to [%s]", sourceValue.getClass().getName(), targetType.getName())); } return result; }
ConvertUtilsConverter implements Converter, Initializable { private <T> T convert(Class<T> targetType, Object sourceValue) { T result; try { result = (T) ConvertUtils.convert(sourceValue, targetType); } catch (ConversionException ex) { throw new org.xwiki.properties.converter.ConversionException("Error while performing type conversion", ex); } if (result == null) { return null; } if (!TypeUtils.isAssignable(targetType, result.getClass())) { throw new org.xwiki.properties.converter.ConversionException( String.format("Failed to find a Converter to convert from [%s] to [%s]", sourceValue.getClass().getName(), targetType.getName())); } return result; } }
ConvertUtilsConverter implements Converter, Initializable { private <T> T convert(Class<T> targetType, Object sourceValue) { T result; try { result = (T) ConvertUtils.convert(sourceValue, targetType); } catch (ConversionException ex) { throw new org.xwiki.properties.converter.ConversionException("Error while performing type conversion", ex); } if (result == null) { return null; } if (!TypeUtils.isAssignable(targetType, result.getClass())) { throw new org.xwiki.properties.converter.ConversionException( String.format("Failed to find a Converter to convert from [%s] to [%s]", sourceValue.getClass().getName(), targetType.getName())); } return result; }  }
ConvertUtilsConverter implements Converter, Initializable { private <T> T convert(Class<T> targetType, Object sourceValue) { T result; try { result = (T) ConvertUtils.convert(sourceValue, targetType); } catch (ConversionException ex) { throw new org.xwiki.properties.converter.ConversionException("Error while performing type conversion", ex); } if (result == null) { return null; } if (!TypeUtils.isAssignable(targetType, result.getClass())) { throw new org.xwiki.properties.converter.ConversionException( String.format("Failed to find a Converter to convert from [%s] to [%s]", sourceValue.getClass().getName(), targetType.getName())); } return result; }  @Override void initialize(); @Override Object convert(Type targetType, Object sourceValue); }
ConvertUtilsConverter implements Converter, Initializable { private <T> T convert(Class<T> targetType, Object sourceValue) { T result; try { result = (T) ConvertUtils.convert(sourceValue, targetType); } catch (ConversionException ex) { throw new org.xwiki.properties.converter.ConversionException("Error while performing type conversion", ex); } if (result == null) { return null; } if (!TypeUtils.isAssignable(targetType, result.getClass())) { throw new org.xwiki.properties.converter.ConversionException( String.format("Failed to find a Converter to convert from [%s] to [%s]", sourceValue.getClass().getName(), targetType.getName())); } return result; }  @Override void initialize(); @Override Object convert(Type targetType, Object sourceValue);  }