How do I properly design this, so it would work:
In class Property<E>:
public void addPropertyChangedListener(OnPropertyChangedListener<E> listener) {
listeners.add(listener);
}
In class ViewModelBase:
public void addPropertyChangedListener(String propertyName, OnPropertyChangedListener<?> listener) {
Property<?> property = properties.get(propertyName);
property.addPropertyChangedListener(listener); // I get error here
}
Error I get:
The method addPropertyChangedListener(Property.OnPropertyChangedListener<capture#5-of ?>)
in the type Property<capture#5-of ?> is not applicable for the arguments
(Property.OnPropertyChangedListener<capture#6-of ?>)
properties.get(PropertyName)is aProperty, correct?Eis defined. You can't add a...Listener<?>where a...Listener<E>is expected, but it's hard to say more based on the current code.ViewModelBase.addPropertyChangedListenerand use the type variable everywhere you are using?.