• 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

75.0
/src/main/java/ch/jalu/configme/properties/builder/ArrayPropertyBuilder.java
1
package ch.jalu.configme.properties.builder;
2

3
import ch.jalu.configme.properties.ArrayProperty;
4
import ch.jalu.configme.properties.Property;
5
import ch.jalu.configme.properties.types.ArrayPropertyType;
6
import ch.jalu.configme.properties.types.PropertyType;
7
import org.jetbrains.annotations.NotNull;
8

9
import java.util.ArrayList;
10
import java.util.Arrays;
11
import java.util.List;
12
import java.util.function.BiFunction;
13
import java.util.function.IntFunction;
14

15
public class ArrayPropertyBuilder<E, P extends Property<E[]>> {
16

17
    private String path;
18
    private final List<E> defaultValue = new ArrayList<>();
5✔
19
    private final BiFunction<String, E[], P> createPropertyFunction;
20
    private final IntFunction<E[]> arrayProducer;
21

22
    public ArrayPropertyBuilder(@NotNull BiFunction<String, E[], P> createPropertyFunction,
23
                                @NotNull IntFunction<E[]> arrayProducer) {
2✔
24
        this.createPropertyFunction = createPropertyFunction;
3✔
25
        this.arrayProducer = arrayProducer;
3✔
26
    }
1✔
27

28
    public static <E> @NotNull ArrayPropertyBuilder<E, ArrayProperty<E>> arrayBuilder(
29
                                                                              @NotNull PropertyType<E> entryType,
30
                                                                              @NotNull IntFunction<E[]> arrayProducer) {
31
        return new ArrayPropertyBuilder<>(
8✔
32
            (path, defVal) -> new ArrayProperty<>(path, defVal, entryType, arrayProducer),
8✔
33
            arrayProducer);
34
    }
35

36
    public static <E> @NotNull ArrayPropertyBuilder<E, ArrayProperty<E>> arrayBuilder(
37
                                                                              @NotNull ArrayPropertyType<E> arrayType) {
38
        return new ArrayPropertyBuilder<>(
×
39
            (path, defVal) -> new ArrayProperty<>(path, arrayType, defVal),
×
40
            arrayType.getArrayProducer());
×
41
    }
42

43
    public @NotNull ArrayPropertyBuilder<E, P> path(@NotNull String path) {
44
        this.path = path;
3✔
45
        return this;
2✔
46
    }
47

48
    @SafeVarargs
49
    public final @NotNull ArrayPropertyBuilder<E, P> defaultValue(@NotNull E @NotNull ... entries) {
50
        defaultValue.clear();
3✔
51
        defaultValue.addAll(Arrays.asList(entries));
6✔
52
        return this;
2✔
53
    }
54

55
    public @NotNull ArrayPropertyBuilder<E, P> addToDefaultValue(@NotNull E entry) {
56
        defaultValue.add(entry);
×
57
        return this;
×
58
    }
59

60
    public @NotNull P build() {
61
        PropertyBuilderUtils.requireNonNullPath(path);
4✔
62
        E[] defaultValueArray = defaultValue.stream().toArray(arrayProducer);
7✔
63
        return createPropertyFunction.apply(path, defaultValueArray);
8✔
64
    }
65
}
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