• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

leeonky / test-charm-java / 258

24 Aug 2025 09:55AM UTC coverage: 74.261% (-0.006%) from 74.267%
258

push

circleci

leeonky
Remove arg-range support of method

1 of 1 new or added line in 1 file covered. (100.0%)

3 existing lines in 3 files now uncovered.

8067 of 10863 relevant lines covered (74.26%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.43
/DAL-java/src/main/java/com/github/leeonky/dal/runtime/CurryingMethodGroup.java
1
package com.github.leeonky.dal.runtime;
2

3
import java.util.List;
4
import java.util.Optional;
5
import java.util.function.Predicate;
6

7
import static com.github.leeonky.util.function.Extension.getFirstPresent;
8
import static java.util.Optional.of;
9
import static java.util.stream.Collectors.joining;
10
import static java.util.stream.Collectors.toList;
11

12
public class CurryingMethodGroup implements CurryingMethod {
13
    private final CurryingMethodGroup parent;
14
    private final List<InstanceCurryingMethod> curryingMethods;
15
    private InstanceCurryingMethod resolvedCurryingMethod;
16

17
    CurryingMethodGroup(List<InstanceCurryingMethod> curryingMethods, CurryingMethodGroup parent) {
1✔
18
        this.curryingMethods = curryingMethods;
1✔
19
        this.parent = parent;
1✔
20
    }
1✔
21

22
    @Override
23
    public CurryingMethodGroup call(Object arg) {
24
        return new CurryingMethodGroup(curryingMethods.stream().map(curryingMethod ->
1✔
25
                curryingMethod.call(arg)).collect(toList()), this);
1✔
26
    }
27

28
    @Override
29
    public Object resolve() {
30
        Optional<InstanceCurryingMethod> curryingMethod = getFirstPresent(
1✔
31
                () -> selectCurryingMethod(InstanceCurryingMethod::allParamsSameType),
1✔
32
                () -> selectCurryingMethod(InstanceCurryingMethod::allParamsBaseType),
1✔
33
                () -> selectCurryingMethod(InstanceCurryingMethod::allParamsConvertible));
1✔
34
        return curryingMethod.isPresent() ? setResolveCurryingMethod(curryingMethod.get()).resolve() : this;
1✔
35
    }
36

37
    private InstanceCurryingMethod setResolveCurryingMethod(InstanceCurryingMethod curryingMethod) {
38
        if (parent != null)
1✔
39
            parent.setResolveCurryingMethod(curryingMethod);
1✔
40
        resolvedCurryingMethod = curryingMethod;
1✔
41
        return curryingMethod;
1✔
42
    }
43

44
    private Optional<InstanceCurryingMethod> selectCurryingMethod(Predicate<InstanceCurryingMethod> predicate) {
45
        List<InstanceCurryingMethod> methods = curryingMethods.stream().filter(predicate).collect(toList());
1✔
46
        if (methods.size() > 1) {
1✔
47
            List<InstanceCurryingMethod> highPriorityMethod = methods.stream().filter(StaticCurryingMethod.class::isInstance).collect(toList());
1✔
48
            return of(getFirstPresent(() -> getOnlyOne(highPriorityMethod), () -> getOnlyOne(highPriorityMethod.stream()
1✔
49
                    .filter(InstanceCurryingMethod::isSameInstanceType).collect(toList())))
1✔
50
                    .orElseThrow(() -> new InvalidPropertyException("More than one currying method:\n"
1✔
51
                            + methods.stream().map(instanceCurryingMethod -> "  " + instanceCurryingMethod.toString())
1✔
52
                            .sorted().collect(joining("\n")))));
1✔
53
        }
54
        return methods.stream().findFirst();
1✔
55
    }
56

57
    private Optional<InstanceCurryingMethod> getOnlyOne(List<InstanceCurryingMethod> list) {
58
        if (list.size() == 1)
1✔
59
            return of(list.get(0));
1✔
60
        return Optional.empty();
1✔
61
    }
62

63
    private Optional<InstanceCurryingMethod> queryResolvedMethod() {
UNCOV
64
        return curryingMethods.stream().filter(method -> method.method.equals(resolvedCurryingMethod.method)).findFirst();
×
65
    }
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc