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

leeonky / test-charm-java / 296

15 Sep 2025 02:01PM UTC coverage: 74.593% (+0.4%) from 74.22%
296

push

circleci

leeonky
checking during consistency merge

89 of 94 new or added lines in 6 files covered. (94.68%)

11 existing lines in 6 files now uncovered.

8435 of 11308 relevant lines covered (74.59%)

0.75 hits per line

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

91.3
/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.ArrayList;
6
import java.util.Collections;
7
import java.util.List;
8

9
import static com.github.leeonky.util.function.Extension.not;
10
import static java.util.Arrays.asList;
11
import static java.util.stream.Collectors.toList;
12

13
public class DefaultConsistency<T> implements Consistency<T> {
14
    private static final List<Class<?>> TYPE_PRIORITY = asList(
1✔
15
            FixedValueProducer.class,
16
            ReadOnlyProducer.class,
17
            DependencyProducer.class,
18
            UnFixedValueProducer.class
19
    );
20

21
    private final List<ConsistencyItem<T>> items = new ArrayList<>();
1✔
22
    private final BeanClass<T> type;
23

24
    public DefaultConsistency(Class<T> type) {
1✔
25
        this.type = BeanClass.create(type);
1✔
26
    }
1✔
27

28
    @Override
29
    public BeanClass<T> type() {
30
        return type;
1✔
31
    }
32

33
    @Override
34
    public Consistency<T> link(ConsistencyItem<T> item) {
35
        items.add(item);
1✔
36
        return this;
1✔
37
    }
38

39
    @Override
40
    public void apply(Producer<?> producer) {
41
        List<ConsistencyItem<T>.Resolving> resolvingList = items.stream().map(i -> i.resolving(producer)).collect(toList());
1✔
42
        ConsistencyItem<T>.Resolving dependency = guessDependency(resolvingList);
1✔
43
        resolvingList.stream().filter(not(dependency::equals))
1✔
44
                .forEach(dependent -> dependent.resolve(dependency));
1✔
45
    }
1✔
46

47
    private ConsistencyItem<T>.Resolving guessDependency(List<ConsistencyItem<T>.Resolving> resolvingList) {
48
        for (Class<?> type : TYPE_PRIORITY)
1✔
49
            for (ConsistencyItem<T>.Resolving resolving : resolvingList)
1✔
50
                if (resolving.isProducerType(type))
1✔
51
                    return resolving;
1✔
52
        return resolvingList.get(0);
×
53
    }
54

55
    public boolean merge(DefaultConsistency<?> another) {
56
        if (items.stream().anyMatch(item -> another.items.stream().anyMatch(item::sameProperty))) {
1✔
57
            items.addAll((List) another.items);
1✔
58
            return true;
1✔
59
        }
NEW
60
        return false;
×
61
    }
62

63
    public List<ConsistencyItem<T>> items() {
64
        return Collections.unmodifiableList(items);
1✔
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