mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-25 14:25:04 +07:00
testdata for IDEA-144840
This commit is contained in:
+34
@@ -0,0 +1,34 @@
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class Test {
|
||||
private Map<Pair<String, Number>, BiFunction<Number, Object, BigDecimal>> spec = null;
|
||||
|
||||
public Optional<BigDecimal> fooIn2(Map<String, Optional<Object>> values) {
|
||||
return values.entrySet().stream().map(entry -> {
|
||||
String pathName = entry.getKey();
|
||||
return entry.getValue().flatMap(value ->
|
||||
spec.entrySet().stream().filter(specEntry ->
|
||||
pathName.equals(specEntry.getKey().getLeft())).findFirst().map(specEntry -> {
|
||||
Pair<String, Number> specEntryKey = specEntry.getKey();
|
||||
Number path = specEntryKey.getRight();
|
||||
BiFunction<Number, Object, BigDecimal> compareFunction = specEntry.getValue();
|
||||
return compareFunction.apply(path, value);
|
||||
}));
|
||||
}).flatMap(option -> option.map(Stream::of).orElse(Stream.empty())).reduce(BigDecimal::add);
|
||||
}
|
||||
|
||||
static class Pair<A, B> {
|
||||
public A getLeft() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public B getRight() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user