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

AuthMe / ConfigMe / 29604929628

17 Jul 2026 06:43PM UTC coverage: 99.347%. Remained the same
29604929628

push

github

ljacqu
Extract path methods from PropertyReader, rename "key" to "path"

559 of 574 branches covered (97.39%)

7 of 7 new or added lines in 1 file covered. (100.0%)

1 existing line in 1 file now uncovered.

1674 of 1685 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

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

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

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

39
    /**
40
     * Returns the object at the given path, or null if absent.
41
     *
42
     * @param path the path to retrieve the value for
43
     * @return the value, or null if there is none
44
     * @deprecated Use {@link #getValue}
45
     */
46
    @Deprecated
47
    default @Nullable Object getObject(@NotNull String path) {
UNCOV
48
        return getValue(path);
×
49
    }
50

51
    /**
52
     * Returns the value of the given path as a String if available.
53
     *
54
     * @param path the path to retrieve a String for
55
     * @return the value as a String, or null if not applicable or unavailable
56
     * @deprecated read the value with a {@link StringProperty},
57
     *             or call {@link #getValue} and perform your own casts
58
     */
59
    @Deprecated
60
    default @Nullable String getString(@NotNull String path) {
61
        StringProperty strProperty = new StringProperty(path, "");
6✔
62
        PropertyValue<String> value = strProperty.determineValue(this);
4✔
63
        return value.isValidInResource() ? value.getValue() : null;
9✔
64
    }
65

66
    /**
67
     * Returns the value of the given path as an integer if available.
68
     *
69
     * @param path the path to retrieve an integer for
70
     * @return the value as integer, or null if not applicable or unavailable
71
     * @deprecated read the value with an {@link IntegerProperty},
72
     *             or call {@link #getValue} and perform your own casts
73
     */
74
    @Deprecated
75
    default @Nullable Integer getInt(@NotNull String path) {
76
        IntegerProperty intProperty = new IntegerProperty(path, 0);
6✔
77
        PropertyValue<Integer> value = intProperty.determineValue(this);
4✔
78
        return value.isValidInResource() ? value.getValue() : null;
8!
79
    }
80

81
    /**
82
     * Returns the value of the given path as a double if available.
83
     *
84
     * @param path the path to retrieve a double for
85
     * @return the value as a double, or null if not applicable or unavailable
86
     * @deprecated read the value with an {@link DoubleProperty},
87
     *             or call {@link #getValue} and perform your own casts
88
     */
89
    @Deprecated
90
    default @Nullable Double getDouble(@NotNull String path) {
91
        DoubleProperty doubleProperty = new DoubleProperty(path, 0);
6✔
92
        PropertyValue<Double> value = doubleProperty.determineValue(this);
4✔
93
        return value.isValidInResource() ? value.getValue() : null;
9✔
94
    }
95

96
    /**
97
     * Returns the value of the given path as a boolean if available.
98
     *
99
     * @param path the path to retrieve a boolean for
100
     * @return the value as a boolean, or null if not applicable or unavailable
101
     * @deprecated read the value with a {@link BooleanProperty},
102
     *             or call {@link #getValue} and perform your own casts
103
     */
104
    @Deprecated
105
    default @Nullable Boolean getBoolean(@NotNull String path) {
106
        BooleanProperty boolProperty = new BooleanProperty(path, true);
6✔
107
        PropertyValue<Boolean> value = boolProperty.determineValue(this);
4✔
108
        return value.isValidInResource() ? value.getValue() : null;
5!
109
    }
110

111
    /**
112
     * Returns the value of the given path as a list if available.
113
     *
114
     * @param path the path to retrieve a list for
115
     * @return the value as a list, or null if not applicable or unavailable
116
     * @deprecated read the value with a {@link ch.jalu.configme.properties.ListProperty ListProperty},
117
     *             or call {@link #getValue} and perform your own casts
118
     */
119
    @Deprecated
120
    default @Nullable List<?> getList(@NotNull String path) {
121
        Object value = getValue(path);
4✔
122
        return value instanceof List<?> ? (List<?>) value : null;
5!
123
    }
124

125
}
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