3
3
* SPDX-License-Identifier: Apache-2.0
4
4
*/
5
5
6
- package io .opentelemetry .sdk . autoconfigure . spi . internal ;
6
+ package io .opentelemetry .api . incubator . config ;
7
7
8
8
import static io .opentelemetry .api .internal .ConfigUtil .defaultIfNull ;
9
9
10
- import io .opentelemetry .sdk .autoconfigure .spi .ConfigProperties ;
11
- import io .opentelemetry .sdk .autoconfigure .spi .ConfigurationException ;
12
10
import java .util .List ;
13
11
import java .util .Set ;
14
12
import javax .annotation .Nullable ;
15
13
16
14
/**
17
- * An interface for accessing structured configuration data.
15
+ * An interface for accessing declarative configuration data.
18
16
*
19
- * <p>An instance of {@link StructuredConfigProperties } is equivalent to a <a
17
+ * <p>An instance of {@link DeclarativeConfigProperties } is equivalent to a <a
20
18
* href="https://yaml.org/spec/1.2.2/#3211-nodes">YAML mapping node</a>. It has accessors for
21
19
* reading scalar properties, {@link #getStructured(String)} for reading children which are
22
20
* themselves mappings, and {@link #getStructuredList(String)} for reading children which are
25
23
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
26
24
* at any time.
27
25
*/
28
- public interface StructuredConfigProperties {
26
+ public interface DeclarativeConfigProperties {
29
27
30
28
/**
31
- * Return an empty {@link StructuredConfigProperties } instance.
29
+ * Return an empty {@link DeclarativeConfigProperties } instance.
32
30
*
33
31
* <p>Useful for walking the tree without checking for null. For example, to access a string key
34
32
* nested at .foo.bar.baz, call: {@code config.getStructured("foo", empty()).getStructured("bar",
35
33
* empty()).getString("baz")}.
36
34
*/
37
- static StructuredConfigProperties empty () {
38
- return EmptyStructuredConfigProperties .getInstance ();
35
+ static DeclarativeConfigProperties empty () {
36
+ return EmptyDeclarativeConfigProperties .getInstance ();
39
37
}
40
38
41
39
/**
42
40
* Returns a {@link String} configuration property.
43
41
*
44
42
* @return null if the property has not been configured
45
- * @throws ConfigurationException if the property is not a valid scalar string
43
+ * @throws DeclarativeConfigException if the property is not a valid scalar string
46
44
*/
47
45
@ Nullable
48
46
String getString (String name );
@@ -52,7 +50,7 @@ static StructuredConfigProperties empty() {
52
50
*
53
51
* @return a {@link String} configuration property or {@code defaultValue} if a property with
54
52
* {@code name} has not been configured
55
- * @throws ConfigurationException if the property is not a valid scalar string
53
+ * @throws DeclarativeConfigException if the property is not a valid scalar string
56
54
*/
57
55
default String getString (String name , String defaultValue ) {
58
56
return defaultIfNull (getString (name ), defaultValue );
@@ -63,7 +61,7 @@ default String getString(String name, String defaultValue) {
63
61
* {@link Boolean#parseBoolean(String)} for handling the values.
64
62
*
65
63
* @return null if the property has not been configured
66
- * @throws ConfigurationException if the property is not a valid scalar boolean
64
+ * @throws DeclarativeConfigException if the property is not a valid scalar boolean
67
65
*/
68
66
@ Nullable
69
67
Boolean getBoolean (String name );
@@ -73,7 +71,7 @@ default String getString(String name, String defaultValue) {
73
71
*
74
72
* @return a {@link Boolean} configuration property or {@code defaultValue} if a property with
75
73
* {@code name} has not been configured
76
- * @throws ConfigurationException if the property is not a valid scalar boolean
74
+ * @throws DeclarativeConfigException if the property is not a valid scalar boolean
77
75
*/
78
76
default boolean getBoolean (String name , boolean defaultValue ) {
79
77
return defaultIfNull (getBoolean (name ), defaultValue );
@@ -86,7 +84,7 @@ default boolean getBoolean(String name, boolean defaultValue) {
86
84
* {@link Long#intValue()} which may result in loss of precision.
87
85
*
88
86
* @return null if the property has not been configured
89
- * @throws ConfigurationException if the property is not a valid scalar integer
87
+ * @throws DeclarativeConfigException if the property is not a valid scalar integer
90
88
*/
91
89
@ Nullable
92
90
Integer getInt (String name );
@@ -99,7 +97,7 @@ default boolean getBoolean(String name, boolean defaultValue) {
99
97
*
100
98
* @return a {@link Integer} configuration property or {@code defaultValue} if a property with
101
99
* {@code name} has not been configured
102
- * @throws ConfigurationException if the property is not a valid scalar integer
100
+ * @throws DeclarativeConfigException if the property is not a valid scalar integer
103
101
*/
104
102
default int getInt (String name , int defaultValue ) {
105
103
return defaultIfNull (getInt (name ), defaultValue );
@@ -109,7 +107,7 @@ default int getInt(String name, int defaultValue) {
109
107
* Returns a {@link Long} configuration property.
110
108
*
111
109
* @return null if the property has not been configured
112
- * @throws ConfigurationException if the property is not a valid scalar long
110
+ * @throws DeclarativeConfigException if the property is not a valid scalar long
113
111
*/
114
112
@ Nullable
115
113
Long getLong (String name );
@@ -119,7 +117,7 @@ default int getInt(String name, int defaultValue) {
119
117
*
120
118
* @return a {@link Long} configuration property or {@code defaultValue} if a property with {@code
121
119
* name} has not been configured
122
- * @throws ConfigurationException if the property is not a valid scalar long
120
+ * @throws DeclarativeConfigException if the property is not a valid scalar long
123
121
*/
124
122
default long getLong (String name , long defaultValue ) {
125
123
return defaultIfNull (getLong (name ), defaultValue );
@@ -129,7 +127,7 @@ default long getLong(String name, long defaultValue) {
129
127
* Returns a {@link Double} configuration property.
130
128
*
131
129
* @return null if the property has not been configured
132
- * @throws ConfigurationException if the property is not a valid scalar double
130
+ * @throws DeclarativeConfigException if the property is not a valid scalar double
133
131
*/
134
132
@ Nullable
135
133
Double getDouble (String name );
@@ -139,7 +137,7 @@ default long getLong(String name, long defaultValue) {
139
137
*
140
138
* @return a {@link Double} configuration property or {@code defaultValue} if a property with
141
139
* {@code name} has not been configured
142
- * @throws ConfigurationException if the property is not a valid scalar double
140
+ * @throws DeclarativeConfigException if the property is not a valid scalar double
143
141
*/
144
142
default double getDouble (String name , double defaultValue ) {
145
143
return defaultIfNull (getDouble (name ), defaultValue );
@@ -153,8 +151,8 @@ default double getDouble(String name, double defaultValue) {
153
151
* @param scalarType the scalar type, one of {@link String}, {@link Boolean}, {@link Long} or
154
152
* {@link Double}
155
153
* @return a {@link List} configuration property, or null if the property has not been configured
156
- * @throws ConfigurationException if the property is not a valid sequence of scalars, or if {@code
157
- * scalarType} is not supported
154
+ * @throws DeclarativeConfigException if the property is not a valid sequence of scalars, or if
155
+ * {@code scalarType} is not supported
158
156
*/
159
157
@ Nullable
160
158
<T > List <T > getScalarList (String name , Class <T > scalarType );
@@ -163,56 +161,58 @@ default double getDouble(String name, double defaultValue) {
163
161
* Returns a {@link List} configuration property. Entries which are not strings are converted to
164
162
* their string representation.
165
163
*
166
- * @see ConfigProperties#getList(String name)
164
+ * @param name the property name
165
+ * @param scalarType the scalar type, one of {@link String}, {@link Boolean}, {@link Long} or
166
+ * {@link Double}
167
167
* @return a {@link List} configuration property or {@code defaultValue} if a property with {@code
168
168
* name} has not been configured
169
- * @throws ConfigurationException if the property is not a valid sequence of scalars
169
+ * @throws DeclarativeConfigException if the property is not a valid sequence of scalars
170
170
*/
171
171
default <T > List <T > getScalarList (String name , Class <T > scalarType , List <T > defaultValue ) {
172
172
return defaultIfNull (getScalarList (name , scalarType ), defaultValue );
173
173
}
174
174
175
175
/**
176
- * Returns a {@link StructuredConfigProperties } configuration property.
176
+ * Returns a {@link DeclarativeConfigProperties } configuration property.
177
177
*
178
178
* @return a map-valued configuration property, or {@code null} if {@code name} has not been
179
179
* configured
180
- * @throws ConfigurationException if the property is not a mapping
180
+ * @throws DeclarativeConfigException if the property is not a mapping
181
181
*/
182
182
@ Nullable
183
- StructuredConfigProperties getStructured (String name );
183
+ DeclarativeConfigProperties getStructured (String name );
184
184
185
185
/**
186
- * Returns a {@link StructuredConfigProperties } configuration property.
186
+ * Returns a list of {@link DeclarativeConfigProperties } configuration property.
187
187
*
188
188
* @return a map-valued configuration property, or {@code defaultValue} if {@code name} has not
189
189
* been configured
190
- * @throws ConfigurationException if the property is not a mapping
190
+ * @throws DeclarativeConfigException if the property is not a mapping
191
191
*/
192
- default StructuredConfigProperties getStructured (
193
- String name , StructuredConfigProperties defaultValue ) {
192
+ default DeclarativeConfigProperties getStructured (
193
+ String name , DeclarativeConfigProperties defaultValue ) {
194
194
return defaultIfNull (getStructured (name ), defaultValue );
195
195
}
196
196
197
197
/**
198
- * Returns a list of {@link StructuredConfigProperties } configuration property.
198
+ * Returns a list of {@link DeclarativeConfigProperties } configuration property.
199
199
*
200
200
* @return a list of map-valued configuration property, or {@code null} if {@code name} has not
201
201
* been configured
202
- * @throws ConfigurationException if the property is not a sequence of mappings
202
+ * @throws DeclarativeConfigException if the property is not a sequence of mappings
203
203
*/
204
204
@ Nullable
205
- List <StructuredConfigProperties > getStructuredList (String name );
205
+ List <DeclarativeConfigProperties > getStructuredList (String name );
206
206
207
207
/**
208
- * Returns a list of {@link StructuredConfigProperties } configuration property.
208
+ * Returns a list of {@link DeclarativeConfigProperties } configuration property.
209
209
*
210
210
* @return a list of map-valued configuration property, or {@code defaultValue} if {@code name}
211
211
* has not been configured
212
- * @throws ConfigurationException if the property is not a sequence of mappings
212
+ * @throws DeclarativeConfigException if the property is not a sequence of mappings
213
213
*/
214
- default List <StructuredConfigProperties > getStructuredList (
215
- String name , List <StructuredConfigProperties > defaultValue ) {
214
+ default List <DeclarativeConfigProperties > getStructuredList (
215
+ String name , List <DeclarativeConfigProperties > defaultValue ) {
216
216
return defaultIfNull (getStructuredList (name ), defaultValue );
217
217
}
218
218
0 commit comments