Question: I want to use generic class as items in `PagingList<>`

```
interface GenericInterface{}
class GenericImplementation: GenericInterface{}

```

As Kotlin doc state: [here](https://kotlinlang.org/docs/reference/generics.html) inheritance **in list** isn't possible, although I can declare generic type of Parameter of ***T***

```
public abstract class PagedListAdapter<T, VH extends RecyclerView.ViewHolder>

```

like 

```
class MAdapter: PagedListAdapter<GenericInterface, MAdapter.ViewHolder>(DIFF_CALLBACK){...}

```

I cannot pass generic list to it 

```
mAdapter.setList(listOfGenericImplementation)

```

because `out`, `in` modifiers are not accepted in Type projections

```
PagedListAdapter<in/out GenericInterface, ..>(..){...}

```

Is there any workaround for this?

Answer: 
Ok so I had this same problem but couldn't find anything on it except this question, but after a while I figured it out and the way I did it was to define the generic in your own class and then pass it onto the `PagedListAdapter`, for example:

You would initiate it like this:

```
var adapter: MAdapter<GenericImplementation, MAdapter.ViewHolder>

```

And then your adapter class would look like this:

```
class MAdapter<T : GenericInterface, VH : RecyclerView.ViewHolder> : PagedListAdapter<T, VH>(
    object : DiffCallback<T>() {
        override fun areItemsTheSame(oldItem: T, newItem: T): Boolean =
                oldItem.id == newItem.id

        override fun areContentsTheSame(oldItem: T, newItem: T): Boolean =
                oldItem == newItem
    }) {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH = 
                MAdapter.ViewHolder(parent)

    override fun onBindViewHolder(holder: VH, position: Int) {
        holder.bindTo(getItem(position)!!)
    }
}

```

As you can see the `DiffCallback` has to be inline instead of the norm of putting it in the companion object.
```
abstract class DiffUtilPagedListAdapter<T : PagingComparable<T>, VH : BaseBindingViewHolder<T>> :
PagedListAdapter<T, VH>

```

The adapter class will accept a class which implements an interface: PagingComparable, the diff util method will be called inside the classes which implemented the interface.

the adapter will be very short and pretty like below

```
class TransactionAdapter :
DiffUtilPagedListAdapter<Transaction, TransactionAdapter.TransactionViewHolder>() {

class TransactionViewHolder(override val binding: ItemTransactionBinding) :
    BaseBindingViewHolder<Transaction>(binding) {

    override fun bind(data: Transaction) {
        binding.transaction = data
    }
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TransactionViewHolder {
    return TransactionViewHolder(createBinding(R.layout.item_transaction, parent))
}}

```

with the paging and MVVM and databinding, time saving!

you can read more [here](https://github.com/komayip/Android-Common-Lib/blob/develop/commonlib/src/main/java/com/komayip/commonlib/base/recyclerView/diffutil/paging/DiffUtilPagedListAdapter.kt)