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

leeonky / test-charm-java / 249

12 May 2025 09:46AM UTC coverage: 74.26% (-0.03%) from 74.288%
249

push

circleci

leeonky
Rename

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

21 existing lines in 5 files now uncovered.

8075 of 10874 relevant lines covered (74.26%)

0.74 hits per line

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

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

3
import java.util.Iterator;
4
import java.util.List;
5
import java.util.stream.Collectors;
6
import java.util.stream.Stream;
7
import java.util.stream.StreamSupport;
8

9
import static java.lang.String.format;
10

11
public abstract class DALCollectionBase<E> implements DALCollection<E> {
1✔
12

13
    @Override
14
    public E getByIndex(int index) {
15
        try {
16
            if (index < 0) {
1✔
17
                return requireLimitedCollection("Not support negative index in infinite collection")
1✔
18
                        .getByPosition(size() + index);
1✔
19
            }
20
            return getByPosition(index - firstIndex());
1✔
21
        } catch (IndexOutOfBoundsException e) {
1✔
22
            throw new IndexOutOfBoundsException(format("Index out of bounds (%d), first index is: %d",
1✔
23
                    index, firstIndex()));
1✔
24
        }
25
    }
26

27
    @Override
28
    public int firstIndex() {
29
        return 0;
1✔
30
    }
31

32
    @Override
33
    public DALCollectionBase<E> requireLimitedCollection(String message) {
34
        if (infinite())
1✔
35
            throw new InfiniteCollectionException(message);
1✔
36
        return this;
1✔
37
    }
38

39
    protected abstract E getByPosition(int position);
40

41
    @Override
42
    public List<E> collect() {
43
        return requireLimitedCollection("Not supported for infinite collection").stream()
1✔
44
                .map(IndexedElement::value).collect(Collectors.toList());
1✔
45
    }
46

47
    @Override
48
    public Stream<E> values() {
49
        return stream().map(IndexedElement::value);
1✔
50
    }
51

52
    @Override
53
    public Stream<Integer> indexes() {
54
        return stream().map(IndexedElement::index);
1✔
55
    }
56

57
    @Override
58
    public <R> DALCollectionBase<R> map(IndexedElement.Mapper<? super E, ? extends R> mapper) {
59
        return new DALCollectionBase<R>() {
1✔
60
            @Override
61
            public int size() {
UNCOV
62
                return DALCollectionBase.this.size();
×
63
            }
64

65
            @Override
66
            public int firstIndex() {
67
                return DALCollectionBase.this.firstIndex();
1✔
68
            }
69

70
            @Override
71
            protected R getByPosition(int position) {
72
                return mapper.apply(position + firstIndex(), DALCollectionBase.this.getByPosition(position));
1✔
73
            }
74

75
            @Override
76
            public Iterator<IndexedElement<R>> iterator() {
77
                return new Iterator<IndexedElement<R>>() {
1✔
78
                    final Iterator<IndexedElement<E>> iterator = (DALCollectionBase.this).iterator();
1✔
79

80
                    @Override
81
                    public boolean hasNext() {
82
                        return iterator.hasNext();
1✔
83
                    }
84

85
                    @Override
86
                    public IndexedElement<R> next() {
87
                        return iterator.next().map(mapper);
1✔
88
                    }
89
                };
90
            }
91

92
            @Override
93
            public boolean infinite() {
94
                return DALCollectionBase.this.infinite();
1✔
95
            }
96
        };
97
    }
98

99
    @Override
100
    public Stream<IndexedElement<E>> stream() {
101
        return StreamSupport.stream(spliterator(), false);
1✔
102
    }
103

104
    @Override
105
    public boolean infinite() {
106
        return false;
1✔
107
    }
108

109
    @Override
110
    public DALCollection<Object> limit(int size) {
UNCOV
111
        return new CollectionDALCollection<Object>(values().limit(size).collect(Collectors.toList())) {
×
112
            @Override
113
            public int firstIndex() {
UNCOV
114
                return DALCollectionBase.this.firstIndex();
×
115
            }
116
        };
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