I have the below specified behavior.
interface ValueEditorPopupView<T> {
void setValue(T value);
void setApplyEnabled();
}
abstract class ValueEditorPopup<T> implements ValueEditorPopupView<T> {
@Override
public void setApplyEnabled() {
System.out.println("In ValueEditorPopup.setApplyEnabled()");
}
}
class ListEditorTextField {
private final ValueEditorPopup<String> popup;
ListEditorTextField() {
popup = new ValueEditorPopup<>() {
@Override
public void setValue(String value) {
System.out.println("In Anonymous Class impl setValue()");
}
// When I add a method that is NOT defined in the abstract class/interface
// I get an error for using the diamond operator in the class declaration above
// "Cannot use '<>' due to non-private method which
// doesn't override or implement a method from a supertype"
// This error clears if I explicitly specify `new ValueEditorPopup<String>(){}`
// in the anonymous class instantiation or
// add `getValues` to the abstract class/interface.
public void getValues() {}
};
}
}
As noted in a comment in the code above, when I add a method that is NOT defined in the abstract class/interface I get an error for using the diamond operator in the class declaration above:
"Cannot use '<>' due to non-private method which doesn't override or implement a method from a supertype"
This error clears if I explicitly specify new ValueEditorPopup<String>(){} in the anonymous class instantiation or add getValues to the abstract class/interface.
I don't understand why the error is being caused and why adding those methods/types fixes it. Not sure what I am missing here.