1

I have this method:

public <T> void onMultipleSelectionTextFinished(
          @NonNull ArrayList<FMultipleSelectionText.HolderItem<T>> holderItems, 
          int payload) {
    // check here
}

How can I check inside of it that holderItem is of type ArrayList<FMultipleSelectionText.HolderItem<EFunction>> and if it is then cast it to that and handle if in a special way ?

EDIT:

I tried using instanceof but it says this:

enter image description here

Also, I went by the rout of castig it to Object first and then castig it again to what I needed, but it's not an elegant solution :(

Nicolas Filotto
  • 43,537
  • 11
  • 94
  • 122
AndreiBogdan
  • 10,858
  • 13
  • 58
  • 106

1 Answers1

1

You cannot do that at the compile time because of TypeErasure at runtime. Alternatively you can do this using reflection, Guava API also provide methods to accomplish this task. Please refer this link.

Community
  • 1
  • 1
Rohit Gulati
  • 542
  • 3
  • 15