Closed Isfirs closed 6 years ago
No, such a method would have to do the logic to see if it can accept the object, return a boolean, then received
would be called and that same logic would need to be done again. A listener does not need to use a list of instanceof checks, it can use a HashSet
switch (wrapper.type) {
case something:
YourClass object = (YourClass)wrapper.object;
break;
}
Isn't it a better way to ask the
listener
if it may accept the Object by calling aListener#doesAccept(Object):bool
orListener#doesAccept(Class):bool
? (I don't care the actual name, but I prefer theclass
variant).