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

leeonky / test-charm-java / 293

12 Sep 2025 04:43PM UTC coverage: 74.22% (-0.09%) from 74.312%
293

push

circleci

leeonky
create sub list from spec list in spec

33 of 42 new or added lines in 8 files covered. (78.57%)

32 existing lines in 11 files now uncovered.

8234 of 11094 relevant lines covered (74.22%)

0.74 hits per line

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

93.94
/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
import java.util.stream.Stream;
9

10
import static com.github.leeonky.jfactory.Link.Reference.defaultLinkerReference;
11
import static java.util.function.Function.identity;
12

13
abstract class Producer<T> {
14
    public static final Producer PLACE_HOLDER = new Producer<Object>(BeanClass.create(Object.class)) {
1✔
15
        @Override
16
        protected Object produce() {
UNCOV
17
            throw new IllegalStateException("This is a place holder producer, can not produce any value");
×
18
        }
19
    };
20
    private final BeanClass<T> type;
21
    private final ValueCache<T> valueCache = new ValueCache<>();
1✔
22

23
    protected Producer(BeanClass<T> type) {
1✔
24
        this.type = type;
1✔
25
    }
1✔
26

27
    public BeanClass<T> getType() {
28
        return type;
1✔
29
    }
30

31
    protected abstract T produce();
32

33
    public T getValue() {
34
        return valueCache.cache(this::produce);
1✔
35
    }
36

37
    protected void doDependencies() {
38
    }
1✔
39

40
    protected void doLinks(Producer<?> root, PropertyChain base) {
41
    }
1✔
42

43
    public void setChild(String property, Producer<?> producer) {
44
    }
1✔
45

46
    public Optional<Producer<?>> child(String property) {
47
        return Optional.empty();
1✔
48
    }
49

50
    public Producer<?> childOrDefault(String property) {
51
        return child(property).orElse(null);
1✔
52
    }
53

54
    public Producer<?> descendant(PropertyChain property) {
55
        return property.access(this, (producer, subProperty) -> producer.child(subProperty)
1✔
56
                .orElseGet(() -> new ReadOnlyProducer<>(producer, subProperty)), identity());
1✔
57
    }
58

59
    public void changeDescendant(PropertyChain property, BiFunction<Producer<?>, String, Producer<?>> producerFactory) {
60
        String tail = property.tail();
1✔
61
        property.removeTail().access(this, Producer::childOrDefault, Optional::ofNullable).ifPresent(lastObjectProducer ->
1✔
62
                lastObjectProducer.changeChild(tail, producerFactory.apply(lastObjectProducer, tail)));
1✔
63
    }
1✔
64

65
    @SuppressWarnings("unchecked")
66
    public <T> void changeChild(String property, Producer<T> producer) {
67
        Producer<T> origin = (Producer<T>) childOrDefault(property);
1✔
68
        if (origin != producer)
1✔
69
            setChild(property, origin == null ? producer : origin.changeTo(producer));
1✔
70
    }
1✔
71

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

76
    public Stream<Link.Reference<T>> allLinkerReferences(Producer<?> root, PropertyChain absoluteCurrent) {
77
        return Stream.of(defaultLinkerReference(root, absoluteCurrent));
1✔
78
    }
79

80
    public Optional<Producer<?>> createPropertyDefaultValueProducer(PropertyWriter<?> property) {
UNCOV
81
        return Optional.empty();
×
82
    }
83

84
    public Producer<T> getLinkOrigin() {
85
        return this;
1✔
86
    }
87

88
    public Producer<T> changeTo(Producer<T> newProducer) {
89
        return newProducer.changeFrom(this);
1✔
90
    }
91

92
    protected Producer<T> changeFrom(Producer<T> producer) {
93
        return this;
1✔
94
    }
95

96
    protected Producer<T> changeFrom(ObjectProducer<T> producer) {
97
        return this;
1✔
98
    }
99

100
    protected Producer<T> changeTo(DefaultValueProducer<T> newProducer) {
101
        return this;
1✔
102
    }
103

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

107
    protected boolean isFixed() {
108
        return false;
1✔
109
    }
110
}
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