Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generics events #308

Open
marioarrigonineri opened this issue Apr 12, 2017 · 2 comments
Open

generics events #308

marioarrigonineri opened this issue Apr 12, 2017 · 2 comments

Comments

@marioarrigonineri
Copy link

marioarrigonineri commented Apr 12, 2017

Hi,
when registering method event listeners for different generics, event dispatcher calls both
eg:

@EventBusListenerMethod
public void a(EditEntity<Bean1> e){
	System.out.println("a");
}
@EventBusListenerMethod
public void b(EditEntity<Bean2> e){
	System.out.println("b");
}

if i send a new EditEntity < Bean1> () message both methods are called

@johannesh2
Copy link

johannesh2 commented Apr 13, 2017

I was going to report a bug about not able to use payload types with generics e.g. Event<Optional<MyBean>>, but I think this bug is just about the same issue I had. If not, I can report a separate issue

@marioarrigonineri
Copy link
Author

I checked the code and I think this is caused by the fact that generics in java are compiletime only, so when dispatcher checks the list of listeners is not able to distinguish between different typed generics. I'm afraid there is no simple solution without knowing how to retrieve the inner bean in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants