Code:
public void ifChangedString(String key, Consumer<String> consumer) {
...
consumer.accept(getString(key));
}
public void ifChangedBoolean(String key, Consumer<Boolean> consumer) {
...
consumer.accept(getBoolean(key));
}
Is it possible to make single method like public <T> void ifChanged(String key, Class<T> clazz, Consumer<T> consumer)
?
Well obvious solution is public void ifChanged(String key, Consumer<Object> consumer)
but I don't want to use Object
as argument type, better to use several methods like above.
The problem is that for accept
method I need ? super XXX
and only super is Object. So is it possible at all?