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

leeonky / test-charm-java / 356

08 Oct 2025 01:39PM UTC coverage: 75.141% (+5.1%) from 70.03%
356

push

circleci

leeonky
Update version

8817 of 11734 relevant lines covered (75.14%)

0.75 hits per line

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

93.1
/jfactory/src/main/java/com/github/leeonky/jfactory/Coordinate.java
1
package com.github.leeonky.jfactory;
2

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

6
import java.util.ArrayList;
7
import java.util.Collections;
8
import java.util.List;
9
import java.util.stream.Collectors;
10

11
import static com.github.leeonky.jfactory.PropertyChain.propertyChain;
12
import static com.github.leeonky.util.function.Extension.notAllowParallelReduce;
13
import static java.util.Arrays.asList;
14
import static java.util.Collections.singletonList;
15

16
public class Coordinate {
17
    private final List<Index> indexes = new ArrayList<>();
1✔
18

19
    public Coordinate(List<Index> indexes) {
1✔
20
        this.indexes.addAll(indexes);
1✔
21
    }
1✔
22

23
    public List<Index> indexes() {
24
        return indexes;
1✔
25
    }
26

27
    public <C extends Coordinate> C convertTo(BeanClass<C> type) {
28
        return type.newInstance(indexes());
1✔
29
    }
30

31
    public Coordinate reverse() {
32
        return new Coordinate(indexes.stream().map(Index::reverse).collect(Collectors.toList()));
1✔
33
    }
34

35
    public Coordinate shift(int adjust) {
36
        return new Coordinate(indexes().stream().map(i -> i.shift(adjust)).collect(Collectors.toList()));
1✔
37
    }
38

39
    public Coordinate sample(int period, int offset) {
40
        List<Index> indexes = indexes().stream().map(i -> i.sample(period, offset)).collect(Collectors.toList());
1✔
41
        return indexes.contains(null) ? null : new Coordinate(indexes);
1✔
42
    }
43

44
    public Coordinate interpolate(int period, int offset) {
45
        return new Coordinate(indexes().stream().map(i -> i.interpolate(period, offset)).collect(Collectors.toList()));
1✔
46
    }
47

48
    public Coordinate transpose() {
49
        List<Index> indexes = new ArrayList<>(indexes());
1✔
50
        Collections.reverse(indexes);
1✔
51
        return new Coordinate(indexes);
1✔
52
    }
53

54
    PropertyChain join(List<PropertyChain> properties) {
55
        return Zipped.zip(properties, indexes()).stream().reduce(propertyChain(""),
1✔
56
                (p, z) -> p.concat(z.left()).concat(z.right().index()), notAllowParallelReduce());
1✔
57
    }
58

59
    public static class D1 extends Coordinate {
60
        public D1(List<Index> index) {
61
            super(require(index, 1));
1✔
62
        }
1✔
63

64
        public Index index() {
65
            return indexes().get(0);
1✔
66
        }
67
    }
68

69
    public static class D2 extends Coordinate {
70
        public D2(List<Index> index) {
71
            super(require(index, 2));
1✔
72
        }
1✔
73

74
        public Index index0() {
75
            return indexes().get(0);
1✔
76
        }
77

78
        public Index index1() {
79
            return indexes().get(1);
1✔
80
        }
81
    }
82

83
    public static D1 d1(Index index) {
84
        return new D1(singletonList(index));
1✔
85
    }
86

87
    public static D2 d2(Index index0, Index index1) {
88
        return new D2(asList(index0, index1));
1✔
89
    }
90

91
    private static List<Index> require(List<Index> indexes, int size) {
92
        if (indexes.size() != size)
1✔
93
            throw new IllegalArgumentException("Coordinate size not match");
×
94
        return indexes;
1✔
95
    }
96

97
    @Override
98
    public String toString() {
99
        return indexes.stream().map(Index::toString).collect(Collectors.joining(","));
×
100
    }
101
}
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