Since the Class<?> target parameter of ConsumerListener's constructors use wildcard types, it cannot infer the lambda type and doesn't let you access its members without casting.
Before:
After:
Note: It was possible to manually specify the parameter type to get around this (new ConsumerListener<Event>(Event.class, Event::method)), however this involves specifying the target type twice so it's not ideal.
Since the
Class<?> target
parameter ofConsumerListener
's constructors use wildcard types, it cannot infer the lambda type and doesn't let you access its members without casting.Before:
After:
Note: It was possible to manually specify the parameter type to get around this (
new ConsumerListener<Event>(Event.class, Event::method)
), however this involves specifying the target type twice so it's not ideal.