I created a simple Counter class:
public class Counter<T> extends HashMap<T, Long> {
public Counter() {
}
public void increase(T key) {
put(key, getOrDefault(key, 0l) + 1);
}
}
In my code, I call the increase() method and then use Map method to access the data, e.g.
Counter<Integer> counter = new Counter<>();
for (Integer i: ... some collection ...)
counter.increase(i);
Intellij highlights the declaration of counter
(first line in last snippet) with warning colour, and the tooltip message says
Contents of collection are queried, but never updated.
Obviously I can just ignore this warning, but is there a way to convince Intellij nothing is wrong with my code?
I am using 14.0.2 community edition.