TypeConverter extends AbstractConverter<Type> { @Override protected Type convertToType(Type type, Object value) { Type result = null; if (value != null) { String valueString = value.toString(); try { result = ReflectionUtils.unserializeType(valueString, Thread.currentThread().getContextClassLoader()); } catch (ClassNotFoundException e) { throw new ConversionException("Invalid Type [" + valueString + "]", e); } } return result; }    }
@Test void convertToType() { Type simpleType = ComponentRole.class; assertEquals(simpleType, this.converterManager.convert(Type.class, "org.xwiki.component.descriptor.ComponentRole")); Type genericsType = new DefaultParameterizedType(null, ComponentRole.class, String.class); assertEquals(genericsType, this.converterManager.convert(Type.class, "org.xwiki.component.descriptor.ComponentRole<java.lang.String>")); }