0

I have a class that would like to implement 2 different kinds of MapChangeListeners, when I use the code below I get an error:

public class ArtistsDetailsController implements DetailsController, MapChangeListener<Integer, PaginatedResult<Track>>, MapChangeListener<Integer, PaginatedResult<Album>>{}

The error is given because i implement MapChangeListener 2 times, despite the fact they are different. How can I implement 2 MapChangeListeners?

  • 1
    They aren't different, due to [type erasure](https://stackoverflow.com/questions/313584/what-is-the-concept-of-erasure-in-generics-in-java). Why not just add two listeners via `map.addListener(c -> { ... })`? – Slaw Apr 12 '20 at 18:06
  • If you insist on using the same object to contain the implementation there's also the option of using references to methods of the same object: `ArtistsDetailsController listener = ...; map1.addListener(listener::onChanged1); map2.addListener(listener::onChanged2);` – fabian Apr 12 '20 at 20:41

0 Answers0