CollectionDatasource of Generic type

Hi, I think this more of a Java questions than pure Cuba-platform, but would appreciate your help.

I’m trying to extend the DataGrid component to make something like a Pivot table. I called my class PivotGrid.
In order to make it work, I need to have a CollectionDatasource for the columns data, in addition to the normal CollectionDatasource used for rows data.

Now, how can I include this CollectionDatasource in my PivotGrid with generic type?
I’m trying as follows:

public class PivotGrid<E extends Entity, F extends Entity> extends WebDataGrid<E> {
	protected CollectionDatasource<F,UUID> columnDatasource;
}

But this gives an error in IDE: Bound Mismatch: the type F is not a valid substitute for the bounded parameter <T extends Entity<K>> of the type CollectionDatasource<T,K>

How should I proceed? Do I need a TokenType?

Thanks

Hi!

Look at CollectionDatasource type parameters bounds.

public interface CollectionDatasource<T extends Entity<K>, K> extends Datasource<T>

In your case, the UUID is used as K, so the F must be F extends Entity<UUID>.

The solution is

public class PivotGrid<E extends Entity, F extends Entity<UUID>> extends WebDataGrid<E> {
	protected CollectionDatasource<F,UUID> columnDatasource;
}

That makes sense… Thank you for kindly answering this basic question!