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

AuthMe / ConfigMe / 6022426951

30 Aug 2023 08:26AM UTC coverage: 97.279% (+3.7%) from 93.592%
6022426951

push

github

ljacqu
Draft: collection property types (3)

528 of 546 branches covered (0.0%)

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

1466 of 1507 relevant lines covered (97.28%)

4.44 hits per line

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

94.12
/src/main/java/ch/jalu/configme/properties/types/ArrayPropertyType.java
1
package ch.jalu.configme.properties.types;
2

3
import ch.jalu.configme.properties.convertresult.ConvertErrorRecorder;
4
import org.jetbrains.annotations.NotNull;
5
import org.jetbrains.annotations.Nullable;
6

7
import java.util.Arrays;
8
import java.util.Collection;
9
import java.util.List;
10
import java.util.Objects;
11
import java.util.function.IntFunction;
12
import java.util.stream.Collectors;
13

14
public class ArrayPropertyType<T> implements PropertyType<T[]> {
15

16
    private final PropertyType<T> entryType;
17
    private final IntFunction<T[]> arrayProducer;
18

19
    public ArrayPropertyType(@NotNull PropertyType<T> entryType, @NotNull IntFunction<T[]> arrayProducer) {
2✔
20
        Objects.requireNonNull(entryType, "entryType");
4✔
21
        Objects.requireNonNull(arrayProducer, "arrayProducer");
4✔
22
        this.entryType = entryType;
3✔
23
        this.arrayProducer = arrayProducer;
3✔
24
    }
1✔
25

26
    @Override
27
    public T @Nullable [] convert(@Nullable Object object, @NotNull ConvertErrorRecorder errorRecorder) {
28
        if (object instanceof Collection<?>) {
3✔
29
            Collection<?> coll = (Collection<?>) object;
3✔
30
            return coll.stream()
6✔
31
                .map(entry -> entryType.convert(entry, errorRecorder))
8✔
32
                .filter(Objects::nonNull)
3✔
33
                .toArray(arrayProducer);
1✔
34
        }
35

36
        return null;
2✔
37
    }
38

39
    @Override
40
    public @Nullable List<?> toExportValue(T @NotNull [] value) {
41
        return Arrays.stream(value)
9✔
42
            .map(entryType::toExportValue)
1✔
43
            .collect(Collectors.toList());
3✔
44
    }
45

46
    public IntFunction<T[]> getArrayProducer() {
47
        return arrayProducer;
×
48
    }
49
}
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

© 2025 Coveralls, Inc