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

leeonky / test-charm-java / 320

28 Sep 2025 03:56PM UTC coverage: 74.512% (+0.07%) from 74.442%
320

push

circleci

leeonky
one list one property

21 of 21 new or added lines in 2 files covered. (100.0%)

13 existing lines in 7 files now uncovered.

8466 of 11362 relevant lines covered (74.51%)

0.75 hits per line

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

90.32
/jfactory/src/main/java/com/github/leeonky/jfactory/Producer.java
1
package com.github.leeonky.jfactory;
2

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

6
import java.util.Optional;
7
import java.util.function.BiFunction;
8

9
import static java.util.Optional.ofNullable;
10
import static java.util.function.Function.identity;
11

12
abstract class Producer<T> {
13
    private final BeanClass<T> type;
14
    private final ValueCache<T> valueCache = new ValueCache<>();
1✔
15

16
    protected Producer(BeanClass<T> type) {
1✔
17
        this.type = type;
1✔
18
    }
1✔
19

20
    public BeanClass<T> getType() {
21
        return type;
1✔
22
    }
23

24
    protected abstract T produce();
25

26
    public T getValue() {
27
        return valueCache.cache(this::produce);
1✔
28
    }
29

30
    protected void collectConsistent(ObjectProducer<?> root, PropertyChain base) {
31
    }
1✔
32

33
    public void setChild(String property, Producer<?> producer) {
34
    }
1✔
35

36
    public Optional<Producer<?>> child(String property) {
37
        return Optional.empty();
1✔
38
    }
39

40
    public Producer<?> childOrDefault(String property) {
41
        return child(property).orElse(null);
1✔
42
    }
43

44
    public Producer<?> descendant(PropertyChain property) {
45
        return property.access(this, (producer, subProperty) -> ofNullable(producer.childOrDefault(subProperty))
1✔
46
                .orElseGet(() -> new ReadOnlyProducer<>(producer, subProperty)), identity());
1✔
47
    }
48

49
    public void changeDescendant(PropertyChain property, BiFunction<Producer<?>, String, Producer<?>> producerFactory) {
50
        String tail = property.tail();
1✔
51
        property.removeTail().access(this, Producer::childOrDefault, Optional::ofNullable).ifPresent(lastObjectProducer ->
1✔
52
                lastObjectProducer.changeChild(tail, producerFactory.apply(lastObjectProducer, tail)));
1✔
53
    }
1✔
54

55
    @SuppressWarnings("unchecked")
56
    public <T> void changeChild(String property, Producer<T> producer) {
57
        Producer<T> origin = (Producer<T>) childOrDefault(property);
1✔
58
        if (origin != producer)
1✔
59
            setChild(property, origin == null ? producer : origin.changeTo(producer));
1✔
60
    }
1✔
61

62
    public BeanClass<?> getPropertyWriterType(String property) {
63
        return getType().getPropertyWriter(property).getType();
1✔
64
    }
65

66
    public Optional<Producer<?>> createPropertyDefaultValueProducer(PropertyWriter<?> property) {
UNCOV
67
        return Optional.empty();
×
68
    }
69

70
    public Producer<T> getLinkOrigin() {
UNCOV
71
        return this;
×
72
    }
73

74
    public Producer<T> changeTo(Producer<T> newProducer) {
75
        return newProducer.reChangeFrom(this);
1✔
76
    }
77

78
    protected Producer<T> reChangeFrom(Producer<T> producer) {
79
        return this;
1✔
80
    }
81

82
    protected Producer<T> changeFrom(ObjectProducer<T> producer) {
83
        return this;
1✔
84
    }
85

86
    protected Producer<T> changeFrom(OptionalSpecDefaultValueProducer<T> producer) {
UNCOV
87
        return this;
×
88
    }
89

90
    protected Producer<T> reChangeTo(DefaultValueProducer<T> newProducer) {
91
        return this;
1✔
92
    }
93

94
    protected Producer<T> reChangeTo(ConsistencyProducer<T, ?> newProducer) {
95
        return newProducer;
1✔
96
    }
97

98
    protected <T> void setupAssociation(String association, RootInstance<T> instance, ListPersistable cachedChildren) {
99
    }
1✔
100

101
    protected boolean isFixed() {
102
        return false;
1✔
103
    }
104
}
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