嘿,我正在尝试生成这样的类:
public abstract class ResourceListAdapter<T extends ResourceViewHolder> extends RecyclerView.Adapter<T> {}
目前我可以生成:
public abstract class ResourceListAdapter extends RecyclerView.Adapter<?> {}
使用以下代码:
TypeSpec type = TypeSpec.classBuilder(thisClass)
.superclass(ParameterizedTypeName.get(adapterClassName, WildcardTypeName.subtypeOf(Object.class)))
.addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC)
.build();
我也可以做这样的事情:
private ResourceListAdapter<? extends ResourceViewHolder> adapter;
和:
ParameterizedTypeName.get(thisClass,WildcardTypeName.subtypeOf(resourceViewHolderClassName));
但我无法将其结合起来。那你有什么想法吗??