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

leeonky / test-charm-java / 390

18 Oct 2025 04:40PM UTC coverage: 75.298% (+0.01%) from 75.288%
390

push

circleci

leeonky
refactor

8 of 8 new or added lines in 5 files covered. (100.0%)

19 existing lines in 8 files now uncovered.

8895 of 11813 relevant lines covered (75.3%)

0.75 hits per line

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

94.12
/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 Optional<Producer<?>> getChild(String property) {
34
        return Optional.empty();
1✔
35
    }
36

37
    //    TODO  move Auto resolve builder in objectProducer / collectionProducer setchild
38
    protected Producer<?> setChild(String property, Producer<?> producer) {
39
        return producer;
1✔
40
    }
41

42
    public Producer<?> childForUpdate(String property) {
43
        return getChild(property).orElse(null);
1✔
44
    }
45

46
    public Producer<?> childForRead(String property) {
47
        return getChild(property).orElseGet(() -> new ReadOnlyProducer<>(this, property));
1✔
48
    }
49

50
    @SuppressWarnings("unchecked")
51
    public <T> void changeChild(String property, Producer<T> producer) {
52
        Producer<T> origin = (Producer<T>) childForUpdate(property);
1✔
53
        if (origin != producer)
1✔
54
            setChild(property, origin == null ? producer : origin.changeTo(producer));
1✔
55
    }
1✔
56

57
    public Producer<?> descendantForRead(PropertyChain property) {
58
        return property.access(this, Producer::childForRead, identity());
1✔
59
    }
60

61
    public Producer<?> descendantForUpdate(PropertyChain property) {
62
        return property.access(this, (producer, subProperty) -> ofNullable(producer.childForUpdate(subProperty))
1✔
63
                .orElseGet(() -> new ReadOnlyProducer<>(producer, subProperty)), identity());
1✔
64
    }
65

66
    public void changeDescendant(PropertyChain property, BiFunction<Producer<?>, String, Producer<?>> producerFactory) {
67
        String tail = property.tail();
1✔
68
        property.removeTail().access(this, Producer::childForUpdate, Optional::ofNullable).ifPresent(lastObjectProducer ->
1✔
69
                lastObjectProducer.changeChild(tail, producerFactory.apply(lastObjectProducer, tail)));
1✔
70
    }
1✔
71

72
    public BeanClass<?> getPropertyWriterType(String property) {
73
        return getType().getPropertyWriter(property).getType();
1✔
74
    }
75

76
    public Optional<Producer<?>> newDefaultValueProducer(PropertyWriter<T> property) {
UNCOV
77
        return Optional.empty();
×
78
    }
79

80
    public Producer<T> changeTo(Producer<T> newProducer) {
81
        return newProducer.reChangeFrom(this);
1✔
82
    }
83

84
    protected Producer<T> reChangeFrom(Producer<T> producer) {
85
        return this;
1✔
86
    }
87

88
    protected Producer<T> changeFrom(ObjectProducer<T> producer) {
89
        return this;
1✔
90
    }
91

92
    protected Producer<T> changeFrom(OptionalSpecDefaultValueProducer<T> producer) {
UNCOV
93
        return this;
×
94
    }
95

96
    protected Producer<T> reChangeTo(DefaultValueProducer<T> newProducer) {
97
        return this;
1✔
98
    }
99

100
    protected Producer<T> reChangeTo(ConsistencyProducer<T, ?> newProducer) {
101
        return newProducer;
1✔
102
    }
103

104
    protected <R> void setupAssociation(String association, ObjectInstance<R> instance, ListPersistable cachedChildren) {
105
    }
1✔
106

107
    protected boolean isFixed() {
108
        return false;
1✔
109
    }
110

111
    public void verifyPropertyStructureDependent() {
112
    }
1✔
113

114
    //    TODO use T
115
    protected Producer<?> resolveBuilderValueProducer(boolean forQuery) {
116
        return this;
1✔
117
    }
118
}
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