1 |
32838
|
sandro.lab
|
package eu.dnetlib.msro.openaireplus.workflows.nodes.hostedby;
|
2 |
31683
|
michele.ar
|
|
3 |
|
|
import java.io.StringWriter;
|
4 |
|
|
import java.util.Map;
|
5 |
|
|
import java.util.Map.Entry;
|
6 |
|
|
|
7 |
|
|
import com.google.common.collect.Maps;
|
8 |
|
|
|
9 |
32838
|
sandro.lab
|
public class HostedByCounters {
|
10 |
48139
|
alessia.ba
|
|
11 |
31683
|
michele.ar
|
private Map<String, Integer> counters = Maps.newHashMap();
|
12 |
48139
|
alessia.ba
|
|
13 |
31683
|
michele.ar
|
public void increaseCounter(final String dsId) {
|
14 |
|
|
int val = counters.containsKey(dsId) ? counters.get(dsId) + 1 : 1;
|
15 |
|
|
counters.put(dsId, val);
|
16 |
|
|
}
|
17 |
48139
|
alessia.ba
|
|
18 |
31683
|
michele.ar
|
public Map<String, Integer> getCounters() {
|
19 |
|
|
return counters;
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
@Override
|
23 |
|
|
public String toString() {
|
24 |
|
|
final StringWriter sw = new StringWriter();
|
25 |
|
|
sw.append("\n");
|
26 |
|
|
sw.append("**************************************************\n");
|
27 |
|
|
for (Entry<String, Integer> e : counters.entrySet()) {
|
28 |
|
|
sw.append(e.getKey());
|
29 |
|
|
sw.append(" : ");
|
30 |
|
|
sw.append(Integer.toString(e.getValue()));
|
31 |
|
|
sw.append("\n");
|
32 |
|
|
}
|
33 |
|
|
sw.append("**************************************************\n");
|
34 |
|
|
return sw.toString();
|
35 |
|
|
}
|
36 |
|
|
}
|