• 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

90.63
/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.function.Function.identity;
10

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

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

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

29
    protected abstract T produce();
30

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

35
    protected void collectConsistent(ObjectProducer<?> root, PropertyChain base) {
36
    }
1✔
37

38
    public void setChild(String property, Producer<?> producer) {
39
    }
1✔
40

41
    public Optional<Producer<?>> child(String property) {
42
        return Optional.empty();
1✔
43
    }
44

45
    public Producer<?> childOrDefault(String property) {
46
        return child(property).orElse(null);
1✔
47
    }
48

49
    public Producer<?> descendant(PropertyChain property) {
50
        return property.access(this, (producer, subProperty) -> producer.child(subProperty)
1✔
51
                .orElseGet(() -> new ReadOnlyProducer<>(producer, subProperty)), identity());
1✔
52
    }
53

54
    public void changeDescendant(PropertyChain property, BiFunction<Producer<?>, String, Producer<?>> producerFactory) {
55
        String tail = property.tail();
1✔
56
        property.removeTail().access(this, Producer::childOrDefault, Optional::ofNullable).ifPresent(lastObjectProducer ->
1✔
57
                lastObjectProducer.changeChild(tail, producerFactory.apply(lastObjectProducer, tail)));
1✔
58
    }
1✔
59

60
    @SuppressWarnings("unchecked")
61
    public <T> void changeChild(String property, Producer<T> producer) {
62
        Producer<T> origin = (Producer<T>) childOrDefault(property);
1✔
63
        if (origin != producer)
1✔
64
            setChild(property, origin == null ? producer : origin.changeTo(producer));
1✔
65
    }
1✔
66

67
    public BeanClass<?> getPropertyWriterType(String property) {
68
        return getType().getPropertyWriter(property).getType();
1✔
69
    }
70

71
    public Optional<Producer<?>> createPropertyDefaultValueProducer(PropertyWriter<?> property) {
UNCOV
72
        return Optional.empty();
×
73
    }
74

75
    public Producer<T> getLinkOrigin() {
UNCOV
76
        return this;
×
77
    }
78

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

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

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

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

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

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

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