vendredi 17 avril 2015

Use a generic class with type parameters in xmlbean

I search a solution for use with bean a generic class like this:



public class CompositeMapper<T extends Model, U extends Command, C extends Context> implements Mapper<T, U, C>
{
protected List<Mapper<T, U, C>> mappers;

/* ... */
}


I would use a bean like this:



<bean id="beanMapper" class="com.test.CompositeMapper">
<property name="mappers">
<list value-type="com.test.Mapper">
<bean class="com.test.Mapper1"/>
<bean class="com.test.Mapper2"/>
<bean class="com.test.Mapper2"/>
</list>
</property>
</bean>


Streangly, this bean works. But I can use anything that is enter in the generic case, so not specialized.


But I don't find a solution for typed my generic object com.test.Mapper<com.test.MyModel, com.test.MyCommand, com.test.MyContext>, it not possible in value-type. I not found other solution than to create an empty class for replace com.test.CompositeMapper in my bean. For example :



public class MyCompositeMapper extends CompositeMapper<MyModel, MyCommand, MyContext>
{
public MyCompositeMapper()
{
super();
}
}


But I would avoid creating this class, is it possible?


Aucun commentaire:

Enregistrer un commentaire