reference to addValueChangeListener is ambiguous [ERROR] both method addValueChangeListener(com.vaadin.data.HasValue.ValueChangeListener
<
V>
) in com.vaadin.data.HasValue and method addValueChangeListener(com.vaadin.data.HasValue.ValueChangeListener<
T>
) in com.vaadin.ui.AbstractField match
This is the compilation error i am getting during the build of project and the code is as following:
private void setTodos(List<Todo> todos) {
removeAllComponents();
this.todos = todos;
todos.forEach(todo ->{
addComponent(new TodoLayout(todo, this));
});
}
TodoLayout.java has the valueChangeListener which is registering each field to handle the change ...
private CheckBox done;
private TextField text;
public TodoLayout(Todo todo, TodoChangeListener changeListener) {
setSpacing(true);
setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
done = new CheckBox();
text = new TextField();
text.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
text.setWidth("100%");
Binder<Todo> binder = new Binder<>();
binder.forField(text).bind(Todo::getText, Todo::setText);
binder.bind(done, Todo::isDone, Todo::setDone);
binder.setBean(todo);
addComponents(done, text);
Arrays.asList(done, text).forEach(field ->
field.addValueChangeListener(change -> //line where getting the error
changeListener.todoChanged(todo))
);
}
As according to the logic each field is registered with only one change listener, then how it is ambiguous.
Thankyou.