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

leeonky / test-charm-java / 311

27 Sep 2025 10:36AM UTC coverage: 74.329% (+3.1%) from 71.191%
311

push

circleci

leeonky
Remove useless code

4 of 4 new or added lines in 3 files covered. (100.0%)

43 existing lines in 9 files now uncovered.

8397 of 11297 relevant lines covered (74.33%)

0.74 hits per line

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

82.93
/jfactory/src/main/java/com/github/leeonky/jfactory/DefaultConsistency.java
1
package com.github.leeonky.jfactory;
2

3
import com.github.leeonky.util.BeanClass;
4

5
import java.util.*;
6
import java.util.function.Predicate;
7

8
import static com.github.leeonky.jfactory.ConsistencyItem.guessCustomerPositionStackTrace;
9
import static java.util.Collections.singletonList;
10
import static java.util.stream.Collectors.toCollection;
11
import static java.util.stream.Collectors.toList;
12

13
public class DefaultConsistency<T> implements Consistency<T> {
14

15
    final List<ConsistencyItem<T>> items = new ArrayList<>();
1✔
16
    private final BeanClass<T> type;
17
    private final List<StackTraceElement> locations = new ArrayList<>();
1✔
18

19
    public DefaultConsistency(Class<T> type) {
20
        this(BeanClass.create(type));
1✔
21
    }
1✔
22

23
    public DefaultConsistency(BeanClass<T> type) {
24
        this(type, singletonList(guessCustomerPositionStackTrace()));
1✔
25
    }
1✔
26

27
    DefaultConsistency(BeanClass<T> type, List<StackTraceElement> locations) {
1✔
28
        this.type = type;
1✔
29
        this.locations.addAll(locations);
1✔
30
    }
1✔
31

32

33
    @Override
34
    public BeanClass<T> type() {
35
        return type;
1✔
36
    }
37

38
    @Override
39
    public Consistency<T> link(ConsistencyItem<T> item) {
40
        items.add(item);
1✔
41
        return this;
1✔
42
    }
43

44
    public boolean merge(DefaultConsistency<?> another) {
45
        if (items.stream().anyMatch(item -> another.items.stream().anyMatch(item::same))) {
1✔
46
            for (ConsistencyItem item : another.items)
1✔
47
                items.add(item);
1✔
48
            return true;
1✔
49
        }
50
        return false;
1✔
51
    }
52

53
    public String info() {
UNCOV
54
        StringBuilder builder = new StringBuilder();
×
UNCOV
55
        builder.append("  ").append(type().getName()).append(":");
×
UNCOV
56
        for (StackTraceElement location : locations) {
×
UNCOV
57
            builder.append("\n    ").append(location.getClassName()).append(".").append(location.getMethodName())
×
UNCOV
58
                    .append("(").append(location.getFileName()).append(":").append(location.getLineNumber()).append(")");
×
UNCOV
59
        }
×
UNCOV
60
        return builder.toString();
×
61
    }
62

63
    public DefaultConsistency<T> absoluteProperty(PropertyChain base) {
64
        DefaultConsistency<T> absolute = new DefaultConsistency<>(type(), locations);
1✔
65
        items.forEach(item -> absolute.items.add(item.absoluteProperty(base)));
1✔
66
        return absolute;
1✔
67
    }
68

69
    public Resolver resolver(ObjectProducer<?> root) {
70
        return new Resolver(root);
1✔
71
    }
72

73
    public class Resolver {
74
        final Set<ConsistencyItem<T>.Resolver> providers;
75
        private final Set<ConsistencyItem<T>.Resolver> consumers;
76

77
        public Resolver(ObjectProducer<?> root) {
1✔
78
            List<ConsistencyItem<T>.Resolver> itemResolvers = items.stream().map(i -> i.resolver(root, this)).collect(toList());
1✔
79
            providers = itemResolvers.stream().filter(ConsistencyItem.Resolver::hasComposer).collect(toCollection(LinkedHashSet::new));
1✔
80
            consumers = itemResolvers.stream().filter(ConsistencyItem.Resolver::hasDecomposer).collect(toCollection(LinkedHashSet::new));
1✔
81
        }
1✔
82

83
        public Set<PropertyChain> resolve(ConsistencyItem<T>.Resolver provider) {
84
            Set<PropertyChain> resolved = new HashSet<>();
1✔
85
            for (ConsistencyItem<T>.Resolver consumer : consumers)
1✔
86
                if (consumer != provider)
1✔
87
                    resolved.addAll(consumer.resolve(provider));
1✔
88
            return resolved;
1✔
89
        }
90

91
        Optional<ConsistencyItem<T>.Resolver> searchProvider(Predicate<ConsistencyItem<?>.Resolver> condition) {
92
            return providers.stream().filter(condition).findFirst();
1✔
93
        }
94

95
        ConsistencyItem<?>.Resolver defaultProvider() {
96
            return providers.iterator().next();
1✔
97
        }
98
    }
99
}
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