16
16
*/
17
17
package org .apache .logging .log4j .kit .env ;
18
18
19
- import java .nio .charset .Charset ;
20
- import java .time .Duration ;
21
19
import org .apache .logging .log4j .kit .env .internal .PropertiesUtilPropertyEnvironment ;
22
20
import org .jspecify .annotations .Nullable ;
23
21
@@ -34,146 +32,14 @@ static PropertyEnvironment getGlobal() {
34
32
return PropertiesUtilPropertyEnvironment .INSTANCE ;
35
33
}
36
34
37
- /**
38
- * Gets the named property as a boolean value. If the property matches the string {@code "true"} (case-insensitive),
39
- * then it is returned as the boolean value {@code true}. Any other non-{@code null} text in the property is
40
- * considered {@code false}.
41
- *
42
- * @param name the name of the property to look up
43
- * @return the boolean value of the property or {@code false} if undefined.
44
- */
45
- default boolean getBooleanProperty (final String name ) {
46
- return getBooleanProperty (name , false );
47
- }
48
-
49
- /**
50
- * Gets the named property as a boolean value.
51
- *
52
- * @param name the name of the property to look up
53
- * @param defaultValue the default value to use if the property is undefined
54
- * @return the boolean value of the property or {@code defaultValue} if undefined.
55
- */
56
- Boolean getBooleanProperty (String name , Boolean defaultValue );
57
-
58
- /**
59
- * Gets the named property as a Charset value.
60
- *
61
- * @param name the name of the property to look up
62
- * @return the Charset value of the property or {@link Charset#defaultCharset()} if undefined.
63
- */
64
- @ SuppressWarnings ("null" )
65
- default Charset getCharsetProperty (final String name ) {
66
- return getCharsetProperty (name , Charset .defaultCharset ());
67
- }
68
-
69
- /**
70
- * Gets the named property as a Charset value.
71
- *
72
- * @param name the name of the property to look up
73
- * @param defaultValue the default value to use if the property is undefined
74
- * @return the Charset value of the property or {@code defaultValue} if undefined.
75
- */
76
- Charset getCharsetProperty (String name , Charset defaultValue );
77
-
78
- /**
79
- * Gets the named property as a Class value.
80
- *
81
- * @param name the name of the property to look up
82
- * @param upperBound the upper bound for the class
83
- * @return the Class value of the property or {@code null} if it can not be loaded.
84
- */
85
- <T > @ Nullable Class <? extends T > getClassProperty (final String name , final Class <T > upperBound );
86
-
87
- /**
88
- * Gets the named property as a subclass of {@code upperBound}.
89
- *
90
- * @param name the name of the property to look up
91
- * @param defaultValue the default value to use if the property is undefined
92
- * @param upperBound the upper bound for the class
93
- * @return the Class value of the property or {@code defaultValue} if it can not be loaded.
94
- */
95
- <T > Class <? extends T > getClassProperty (String name , Class <? extends T > defaultValue , Class <T > upperBound );
96
-
97
- /**
98
- * Gets the named property as {@link Duration}.
99
- *
100
- * @param name The property name.
101
- * @return The value of the String as a Duration or {@link Duration#ZERO} if it was undefined or could not be parsed.
102
- */
103
- default Duration getDurationProperty (final String name ) {
104
- return getDurationProperty (name , Duration .ZERO );
105
- }
106
-
107
- /**
108
- * Gets the named property as {@link Duration}.
109
- *
110
- * @param name The property name.
111
- * @param defaultValue The default value.
112
- * @return The value of the String as a Duration or {@code defaultValue} if it was undefined or could not be parsed.
113
- */
114
- Duration getDurationProperty (String name , Duration defaultValue );
115
-
116
- /**
117
- * Gets the named property as an integer.
118
- *
119
- * @param name the name of the property to look up
120
- * @return the parsed integer value of the property or {@code 0} if it was undefined or could not be
121
- * parsed.
122
- */
123
- default int getIntegerProperty (final String name ) {
124
- return getIntegerProperty (name , 0 );
125
- }
126
-
127
- /**
128
- * Gets the named property as an integer.
129
- *
130
- * @param name the name of the property to look up
131
- * @param defaultValue the default value to use if the property is undefined
132
- * @return the parsed integer value of the property or {@code defaultValue} if it was undefined or could not be
133
- * parsed.
134
- */
135
- Integer getIntegerProperty (String name , Integer defaultValue );
136
-
137
- /**
138
- * Gets the named property as a long.
139
- *
140
- * @param name the name of the property to look up
141
- * @return the parsed long value of the property or {@code 0} if it was undefined or could not be
142
- * parsed.
143
- */
144
- default long getLongProperty (final String name ) {
145
- return getLongProperty (name , 0L );
146
- }
147
-
148
- /**
149
- * Gets the named property as a long.
150
- *
151
- * @param name the name of the property to look up
152
- * @param defaultValue the default value to use if the property is undefined
153
- * @return the parsed long value of the property or {@code defaultValue} if it was undefined or could not be parsed.
154
- */
155
- Long getLongProperty (String name , Long defaultValue );
156
-
157
35
/**
158
36
* Gets the named property as a String.
159
37
*
160
38
* @param name the name of the property to look up
161
39
* @return the String value of the property or {@code null} if undefined.
162
40
*/
163
41
@ Nullable
164
- String getStringProperty (String name );
165
-
166
- /**
167
- * Gets the named property as a String.
168
- *
169
- * @param name the name of the property to look up
170
- * @param defaultValue the default value to use if the property is undefined
171
- * @return the String value of the property or {@code defaultValue} if undefined.
172
- */
173
- default String getStringProperty (final String name , final String defaultValue ) {
174
- final String prop = getStringProperty (name );
175
- return (prop == null ) ? defaultValue : prop ;
176
- }
42
+ String getProperty (String name );
177
43
178
44
/**
179
45
* Binds properties to class {@code T}.
0 commit comments