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

AuthMe / ConfigMe / 29600249571

17 Jul 2026 05:29PM UTC coverage: 99.346% (-0.06%) from 99.405%
29600249571

push

github

ljacqu
Deprecate casting methods on PropertyReader, add getValue

559 of 574 branches covered (97.39%)

17 of 18 new or added lines in 3 files covered. (94.44%)

1671 of 1682 relevant lines covered (99.35%)

4.6 hits per line

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

93.33
/src/main/java/ch/jalu/configme/resource/PropertyReader.java
1
package ch.jalu.configme.resource;
2

3
import ch.jalu.configme.properties.BooleanProperty;
4
import ch.jalu.configme.properties.DoubleProperty;
5
import ch.jalu.configme.properties.IntegerProperty;
6
import ch.jalu.configme.properties.StringProperty;
7
import ch.jalu.configme.properties.convertresult.PropertyValue;
8
import org.jetbrains.annotations.NotNull;
9
import org.jetbrains.annotations.Nullable;
10

11
import java.util.List;
12
import java.util.Set;
13

14
/**
15
 * A property reader provides values from a resource (e.g. a YAML file) based on whose data the values of properties
16
 * are determined. Property readers typically provide a snapshot of the file's contents, i.e. their values are not
17
 * updated if the underlying file changes.
18
 */
19
public interface PropertyReader {
20

21
    /**
22
     * Returns whether a value is present for the given path. When applicable,
23
     * {@link ch.jalu.configme.properties.Property#determineValue(PropertyReader)} should be favored over
24
     * calling this method as it may make more type-aware checks. This method simply returns whether <i>some value</i>
25
     * exists under the given path.
26
     *
27
     * @param path the path to check
28
     * @return true if there is a value, false otherwise
29
     */
30
    boolean contains(@NotNull String path);
31

32
    /**
33
     * Returns the object at the given path, or null if absent.
34
     *
35
     * @param path the path to retrieve the value for
36
     * @return the value, or null if there is none
37
     */
38
    @Nullable Object getValue(@NotNull String path);
39

40
    /**
41
     * Returns the keys available in the file. Depending on the parameter either all keys are returned,
42
     * or only the keys of the leaf nodes are considered.
43
     *
44
     * @param onlyLeafNodes true if only the paths of leaf nodes should be returned (no intermediate paths)
45
     * @return set of all existing keys (ordered)
46
     */
47
    @NotNull Set<String> getKeys(boolean onlyLeafNodes);
48

49
    /**
50
     * Returns the direct children of the given path which are available in the file. Returns an empty set
51
     * if the path does not exist in the file (never null).
52
     *
53
     * @param path the path whose direct child paths should be looked up
54
     * @return set of all direct children (ordered, never null)
55
     */
56
    @NotNull Set<String> getChildKeys(@NotNull String path);
57

58
    /**
59
     * Returns the object at the given path, or null if absent.
60
     *
61
     * @param path the path to retrieve the value for
62
     * @return the value, or null if there is none
63
     * @deprecated Use {@link #getValue}
64
     */
65
    @Deprecated
66
    default @Nullable Object getObject(@NotNull String path) {
NEW
67
        return getValue(path);
×
68
    }
69

70
    /**
71
     * Returns the value of the given path as a String if available.
72
     *
73
     * @param path the path to retrieve a String for
74
     * @return the value as a String, or null if not applicable or unavailable
75
     * @deprecated read the value with a {@link StringProperty},
76
     *             or call {@link #getValue} and perform your own casts
77
     */
78
    @Deprecated
79
    default @Nullable String getString(@NotNull String path) {
80
        StringProperty strProperty = new StringProperty(path, "");
6✔
81
        PropertyValue<String> value = strProperty.determineValue(this);
4✔
82
        return value.isValidInResource() ? value.getValue() : null;
9✔
83
    }
84

85
    /**
86
     * Returns the value of the given path as an integer if available.
87
     *
88
     * @param path the path to retrieve an integer for
89
     * @return the value as integer, or null if not applicable or unavailable
90
     * @deprecated read the value with an {@link IntegerProperty},
91
     *             or call {@link #getValue} and perform your own casts
92
     */
93
    @Deprecated
94
    default @Nullable Integer getInt(@NotNull String path) {
95
        IntegerProperty intProperty = new IntegerProperty(path, 0);
6✔
96
        PropertyValue<Integer> value = intProperty.determineValue(this);
4✔
97
        return value.isValidInResource() ? value.getValue() : null;
8!
98
    }
99

100
    /**
101
     * Returns the value of the given path as a double if available.
102
     *
103
     * @param path the path to retrieve a double for
104
     * @return the value as a double, or null if not applicable or unavailable
105
     * @deprecated read the value with an {@link DoubleProperty},
106
     *             or call {@link #getValue} and perform your own casts
107
     */
108
    @Deprecated
109
    default @Nullable Double getDouble(@NotNull String path) {
110
        DoubleProperty doubleProperty = new DoubleProperty(path, 0);
6✔
111
        PropertyValue<Double> value = doubleProperty.determineValue(this);
4✔
112
        return value.isValidInResource() ? value.getValue() : null;
9✔
113
    }
114

115
    /**
116
     * Returns the value of the given path as a boolean if available.
117
     *
118
     * @param path the path to retrieve a boolean for
119
     * @return the value as a boolean, or null if not applicable or unavailable
120
     * @deprecated read the value with a {@link BooleanProperty},
121
     *             or call {@link #getValue} and perform your own casts
122
     */
123
    @Deprecated
124
    default @Nullable Boolean getBoolean(@NotNull String path) {
125
        BooleanProperty boolProperty = new BooleanProperty(path, true);
6✔
126
        PropertyValue<Boolean> value = boolProperty.determineValue(this);
4✔
127
        return value.isValidInResource() ? value.getValue() : null;
5!
128
    }
129

130
    /**
131
     * Returns the value of the given path as a list if available.
132
     *
133
     * @param path the path to retrieve a list for
134
     * @return the value as a list, or null if not applicable or unavailable
135
     * @deprecated read the value with a {@link ch.jalu.configme.properties.ListProperty ListProperty},
136
     *             or call {@link #getValue} and perform your own casts
137
     */
138
    @Deprecated
139
    default @Nullable List<?> getList(@NotNull String path) {
140
        Object value = getValue(path);
4✔
141
        return value instanceof List<?> ? (List<?>) value : null;
5!
142
    }
143

144
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc