• 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/CollectionPropertyBuilder.java
1
package ch.jalu.configme.properties.builder;
2

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

9
import java.util.ArrayList;
10
import java.util.Collection;
11
import java.util.LinkedHashSet;
12
import java.util.List;
13
import java.util.Set;
14
import java.util.function.BiFunction;
15

16
public class CollectionPropertyBuilder<E, C extends Collection<E>, P extends Property<C>> {
17

18
    private String path;
19
    private final C defaultValue;
20
    private final BiFunction<String, C, P> createPropertyFunction;
21

22
    public CollectionPropertyBuilder(@NotNull BiFunction<String, C, P> createPropertyFunction,
23
                                     @NotNull C defaultValue) {
×
24
        this.createPropertyFunction = createPropertyFunction;
×
25
        this.defaultValue = defaultValue;
×
26
    }
×
27

28
    public static <E> @NotNull CollectionPropertyBuilder<E, List<E>, ListProperty<E>> listBuilder(
29
                                                                                   @NotNull PropertyType<E> entryType) {
30
        return new CollectionPropertyBuilder<>(
×
31
            (path, defVal) -> new ListProperty<>(path, entryType, defVal),
×
32
            new ArrayList<>());
33
    }
34

35
    public static <E> @NotNull CollectionPropertyBuilder<E, Set<E>, SetProperty<E>> setBuilder(
36
                                                                                   @NotNull PropertyType<E> entryType) {
37
        return new CollectionPropertyBuilder<>(
×
38
            (path, defVal) -> new SetProperty<>(path, entryType, defVal),
×
39
            new LinkedHashSet<>());
40
    }
41

42
    public static <E, C extends Collection<E>, P extends Property<C>>
43
         @NotNull CollectionPropertyBuilder<E, C, P> collectionBuilder(@NotNull BiFunction<String, C, P> createFunction,
44
                                                                       @NotNull C defaultValue) {
45
        return new CollectionPropertyBuilder<>(createFunction, defaultValue);
×
46
    }
47

48
    public @NotNull CollectionPropertyBuilder<E, C, P> path(@NotNull String path) {
49
        this.path = path;
×
50
        return this;
×
51
    }
52

53
    public @NotNull CollectionPropertyBuilder<E, C, P> addToDefaultValue(@NotNull E entry) {
54
        defaultValue.add(entry);
×
55
        return this;
×
56
    }
57

58
    public @NotNull P build() {
59
        PropertyBuilderUtils.requireNonNullPath(path);
×
60
        return createPropertyFunction.apply(path, defaultValue);
×
61
    }
62
}
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