1
|
package eu.dnetlib.pace.distance.eval;
|
2
|
|
3
|
import java.util.HashMap;
|
4
|
|
5
|
import com.google.common.base.Predicate;
|
6
|
import com.google.common.collect.Iterables;
|
7
|
|
8
|
/**
|
9
|
* Created by claudio on 09/03/16.
|
10
|
*/
|
11
|
public class ConditionEvalMap extends HashMap<String, ConditionEval> {
|
12
|
|
13
|
|
14
|
public ConditionEvalMap mergeFrom(ConditionEvalMap map) {
|
15
|
putAll(map);
|
16
|
return this;
|
17
|
}
|
18
|
|
19
|
public boolean anyNegative() {
|
20
|
return values().stream()
|
21
|
.allMatch(ec -> ec.getResult() < 0);
|
22
|
}
|
23
|
|
24
|
public boolean isZero() {
|
25
|
return result() == 0;
|
26
|
}
|
27
|
|
28
|
public int result() {
|
29
|
int res = 0;
|
30
|
for(ConditionEval ec : values()) {
|
31
|
final int verify = ec.getResult();
|
32
|
if (verify < 0) return -1;
|
33
|
res += verify;
|
34
|
}
|
35
|
return res;
|
36
|
}
|
37
|
|
38
|
}
|