I am working on a graphical interface in Vaadin, with some given classes from my CIO. All this is great, but today I came across the fact that I can not use the lambda expression in the addListener method addListener . This method is as common as an object that uses it. Here is the implementation:
public class ResetButtonForTextField extends AbstractExtension { private final List<ResetButtonClickListener> listeners = new ArrayList<ResetButtonClickListener>(); private void addResetButtonClickedListener (ResetButtonClickListener listener) { listeners.add(listener); }
To use this extension, you must do this:
ResetButtonForTextField rb=ResetButtonForTextField.extend(button); rb.addResetButtonClickedListener(new ResetButtonClickListener() { @Override public void resetButtonClicked() {
If I use lambda in addResetButtonClickedListener as follows:
rb.addResetButtonClickedListener(ev -> {
The compiler says that
Lambda expression signature does not match resetButtonClicked () function interface method signature
The addResetButtonClickedListener (ResetButtonClickListener) method in the ResetButtonForTextField type is not applicable for arguments ((ev) → {})
Even if I define the lambda expression as follows: (ResetButtonClickListener ev) -> {} still gives an error.
So the question is, why can't I use a lambda expression there? Am I missing something in the code declaration?
source share