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

AuthMe / ConfigMe / 6013592978

29 Aug 2023 02:22PM UTC coverage: 95.279%. First build
6013592978

push

github

ljacqu
New property builder: current working changes

526 of 544 branches covered (0.0%)

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

1453 of 1525 relevant lines covered (95.28%)

4.36 hits per line

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

0.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.PropertyType;
6
import org.jetbrains.annotations.NotNull;
7

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

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

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

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

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

35
    public @NotNull ArrayPropertyBuilder<E, P> path(@NotNull String path) {
36
        this.path = path;
×
37
        return this;
×
38
    }
39

40
    @SafeVarargs
41
    public final @NotNull ArrayPropertyBuilder<E, P> defaultValue(@NotNull E @NotNull ... entries) {
42
        defaultValue.clear();
×
43
        defaultValue.addAll(Arrays.asList(entries));
×
44
        return this;
×
45
    }
46

47
    public @NotNull ArrayPropertyBuilder<E, P> addToDefaultValue(@NotNull E entry) {
48
        defaultValue.add(entry);
×
49
        return this;
×
50
    }
51

52
    public @NotNull P build() {
53
        PropertyBuilderUtils.requireNonNullPath(path);
×
54
        E[] defaultValueArray = defaultValue.stream().toArray(arrayProducer);
×
55
        return createPropertyFunction.apply(path, defaultValueArray);
×
56
    }
57
}
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