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

leeonky / test-charm-java / 212

14 Apr 2025 05:15AM UTC coverage: 74.088% (-0.1%) from 74.209%
212

push

circleci

leeonky
Update version

7957 of 10740 relevant lines covered (74.09%)

0.74 hits per line

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

68.97
/DAL-java/src/main/java/com/github/leeonky/dal/runtime/MetaData.java
1
package com.github.leeonky.dal.runtime;
2

3
import com.github.leeonky.dal.ast.node.DALNode;
4
import com.github.leeonky.dal.runtime.RuntimeContextBuilder.DALRuntimeContext;
5

6
import java.util.ArrayList;
7
import java.util.List;
8
import java.util.Objects;
9

10
import static com.github.leeonky.dal.runtime.ExpressionException.illegalOp2;
11
import static java.lang.String.format;
12

13
public class MetaData extends RuntimeData {
14
    private DALNode inputNode;
15
    private final Object name;
16

17
    public MetaData(DALNode inputNode, Data inputData, Object symbolName, DALRuntimeContext runtimeContext) {
18
        super(inputData, runtimeContext);
1✔
19
        this.inputNode = inputNode;
1✔
20
        name = symbolName;
1✔
21
    }
1✔
22

23
    private MetaData(DALRuntimeContext runtimeContext, Data data, String name) {
24
        super(data, runtimeContext);
1✔
25
        this.name = name;
1✔
26
    }
1✔
27

28
    private final List<Class<?>> callTypes = new ArrayList<>();
1✔
29

30
    public Object callSuper() {
31
        return runtimeContext().fetchSuperMetaFunction(this).orElseThrow(() -> illegalOp2(format(
1✔
32
                        "Local meta property `%s` has no super in type %s", name, callTypes.get(callTypes.size() - 1).getName())))
1✔
33
                .apply(this);
1✔
34
    }
35

36
//    public Object callSuper(Supplier<Object> supplier) {
37
//        setData(() -> {
38
//            Object newData = supplier.get();
39
//            checkType(newData);
40
//            return runtimeContext.wrap(newData);
41
//        });
42
//        return callSuper();
43
//    }
44

45
    public Object callGlobal() {
46
        return runtimeContext().fetchGlobalMetaFunction(this).apply(this);
1✔
47
    }
48

49
//    TODO
50
//    public Object callGlobal(Supplier<Object> supplier) {
51
//        setData(() -> runtimeContext.wrap(supplier.get()));
52
//        return callGlobal();
53
//    }
54

55
    private MetaData newMeta(String name) {
56
        return new MetaData(runtimeContext, data, name);
1✔
57
    }
58

59
    public Object callMeta(String another) {
60
        MetaData metaData = newMeta(another);
1✔
61
        return runtimeContext().fetchGlobalMetaFunction(metaData).apply(metaData);
1✔
62
    }
63

64
//    TODO
65
//    public Object callMeta(String another, Supplier<Object> supplier) {
66
//        MetaData metaData = newMeta(another);
67
//        metaData.setData(() -> runtimeContext.wrap(supplier.get()));
68
//        return runtimeContext().fetchGlobalMetaFunction(metaData).apply(metaData);
69
//    }
70

71
    private void checkType(Object data) {
72
        Class<?> expect = this.data.instance().getClass();
×
73
        Class<?> actual = Objects.requireNonNull(data).getClass();
×
74
        if (actual.isAnonymousClass())
×
75
            actual = actual.getSuperclass();
×
76
        if (!actual.equals(expect))
×
77
            throw illegalOp2(format("Do not allow change data type in callSuper, expect %s but %s",
×
78
                    expect.getName(), actual.getName()));
×
79
    }
×
80

81
    public void addCallType(Class<?> callType) {
82
        callTypes.add(callType);
1✔
83
    }
1✔
84

85
    public boolean calledBy(Class<?> type) {
86
        return callTypes.contains(type);
1✔
87
    }
88

89
    public boolean isInstance(Class<?> type) {
90
        return data.instanceOf(type);
1✔
91
    }
92

93
    public Object name() {
94
        return name;
1✔
95
    }
96

97
    public DALNode inputNode() {
98
        return inputNode;
×
99
    }
100
}
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