33 * SPDX-License-Identifier: Apache-2.0
44 */
55
6- package io .opentelemetry .sdk . autoconfigure . spi . internal ;
6+ package io .opentelemetry .api . incubator . config ;
77
88import static io .opentelemetry .api .internal .ConfigUtil .defaultIfNull ;
99
10- import io .opentelemetry .sdk .autoconfigure .spi .ConfigProperties ;
11- import io .opentelemetry .sdk .autoconfigure .spi .ConfigurationException ;
1210import java .util .List ;
1311import java .util .Set ;
1412import javax .annotation .Nullable ;
1513
1614/**
17- * An interface for accessing structured configuration data.
15+ * An interface for accessing declarative configuration data.
1816 *
19- * <p>An instance of {@link StructuredConfigProperties } is equivalent to a <a
17+ * <p>An instance of {@link DeclarativeConfigProperties } is equivalent to a <a
2018 * href="https://yaml.org/spec/1.2.2/#3211-nodes">YAML mapping node</a>. It has accessors for
2119 * reading scalar properties, {@link #getStructured(String)} for reading children which are
2220 * themselves mappings, and {@link #getStructuredList(String)} for reading children which are
2523 * <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
2624 * at any time.
2725 */
28- public interface StructuredConfigProperties {
26+ public interface DeclarativeConfigProperties {
2927
3028 /**
31- * Return an empty {@link StructuredConfigProperties } instance.
29+ * Return an empty {@link DeclarativeConfigProperties } instance.
3230 *
3331 * <p>Useful for walking the tree without checking for null. For example, to access a string key
3432 * nested at .foo.bar.baz, call: {@code config.getStructured("foo", empty()).getStructured("bar",
3533 * empty()).getString("baz")}.
3634 */
37- static StructuredConfigProperties empty () {
38- return EmptyStructuredConfigProperties .getInstance ();
35+ static DeclarativeConfigProperties empty () {
36+ return EmptyDeclarativeConfigProperties .getInstance ();
3937 }
4038
4139 /**
4240 * Returns a {@link String} configuration property.
4341 *
4442 * @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
4644 */
4745 @ Nullable
4846 String getString (String name );
@@ -52,7 +50,7 @@ static StructuredConfigProperties empty() {
5250 *
5351 * @return a {@link String} configuration property or {@code defaultValue} if a property with
5452 * {@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
5654 */
5755 default String getString (String name , String defaultValue ) {
5856 return defaultIfNull (getString (name ), defaultValue );
@@ -63,7 +61,7 @@ default String getString(String name, String defaultValue) {
6361 * {@link Boolean#parseBoolean(String)} for handling the values.
6462 *
6563 * @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
6765 */
6866 @ Nullable
6967 Boolean getBoolean (String name );
@@ -73,7 +71,7 @@ default String getString(String name, String defaultValue) {
7371 *
7472 * @return a {@link Boolean} configuration property or {@code defaultValue} if a property with
7573 * {@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
7775 */
7876 default boolean getBoolean (String name , boolean defaultValue ) {
7977 return defaultIfNull (getBoolean (name ), defaultValue );
@@ -86,7 +84,7 @@ default boolean getBoolean(String name, boolean defaultValue) {
8684 * {@link Long#intValue()} which may result in loss of precision.
8785 *
8886 * @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
9088 */
9189 @ Nullable
9290 Integer getInt (String name );
@@ -99,7 +97,7 @@ default boolean getBoolean(String name, boolean defaultValue) {
9997 *
10098 * @return a {@link Integer} configuration property or {@code defaultValue} if a property with
10199 * {@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
103101 */
104102 default int getInt (String name , int defaultValue ) {
105103 return defaultIfNull (getInt (name ), defaultValue );
@@ -109,7 +107,7 @@ default int getInt(String name, int defaultValue) {
109107 * Returns a {@link Long} configuration property.
110108 *
111109 * @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
113111 */
114112 @ Nullable
115113 Long getLong (String name );
@@ -119,7 +117,7 @@ default int getInt(String name, int defaultValue) {
119117 *
120118 * @return a {@link Long} configuration property or {@code defaultValue} if a property with {@code
121119 * 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
123121 */
124122 default long getLong (String name , long defaultValue ) {
125123 return defaultIfNull (getLong (name ), defaultValue );
@@ -129,7 +127,7 @@ default long getLong(String name, long defaultValue) {
129127 * Returns a {@link Double} configuration property.
130128 *
131129 * @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
133131 */
134132 @ Nullable
135133 Double getDouble (String name );
@@ -139,7 +137,7 @@ default long getLong(String name, long defaultValue) {
139137 *
140138 * @return a {@link Double} configuration property or {@code defaultValue} if a property with
141139 * {@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
143141 */
144142 default double getDouble (String name , double defaultValue ) {
145143 return defaultIfNull (getDouble (name ), defaultValue );
@@ -153,8 +151,8 @@ default double getDouble(String name, double defaultValue) {
153151 * @param scalarType the scalar type, one of {@link String}, {@link Boolean}, {@link Long} or
154152 * {@link Double}
155153 * @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
158156 */
159157 @ Nullable
160158 <T > List <T > getScalarList (String name , Class <T > scalarType );
@@ -163,56 +161,58 @@ default double getDouble(String name, double defaultValue) {
163161 * Returns a {@link List} configuration property. Entries which are not strings are converted to
164162 * their string representation.
165163 *
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}
167167 * @return a {@link List} configuration property or {@code defaultValue} if a property with {@code
168168 * 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
170170 */
171171 default <T > List <T > getScalarList (String name , Class <T > scalarType , List <T > defaultValue ) {
172172 return defaultIfNull (getScalarList (name , scalarType ), defaultValue );
173173 }
174174
175175 /**
176- * Returns a {@link StructuredConfigProperties } configuration property.
176+ * Returns a {@link DeclarativeConfigProperties } configuration property.
177177 *
178178 * @return a map-valued configuration property, or {@code null} if {@code name} has not been
179179 * configured
180- * @throws ConfigurationException if the property is not a mapping
180+ * @throws DeclarativeConfigException if the property is not a mapping
181181 */
182182 @ Nullable
183- StructuredConfigProperties getStructured (String name );
183+ DeclarativeConfigProperties getStructured (String name );
184184
185185 /**
186- * Returns a {@link StructuredConfigProperties } configuration property.
186+ * Returns a list of {@link DeclarativeConfigProperties } configuration property.
187187 *
188188 * @return a map-valued configuration property, or {@code defaultValue} if {@code name} has not
189189 * been configured
190- * @throws ConfigurationException if the property is not a mapping
190+ * @throws DeclarativeConfigException if the property is not a mapping
191191 */
192- default StructuredConfigProperties getStructured (
193- String name , StructuredConfigProperties defaultValue ) {
192+ default DeclarativeConfigProperties getStructured (
193+ String name , DeclarativeConfigProperties defaultValue ) {
194194 return defaultIfNull (getStructured (name ), defaultValue );
195195 }
196196
197197 /**
198- * Returns a list of {@link StructuredConfigProperties } configuration property.
198+ * Returns a list of {@link DeclarativeConfigProperties } configuration property.
199199 *
200200 * @return a list of map-valued configuration property, or {@code null} if {@code name} has not
201201 * 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
203203 */
204204 @ Nullable
205- List <StructuredConfigProperties > getStructuredList (String name );
205+ List <DeclarativeConfigProperties > getStructuredList (String name );
206206
207207 /**
208- * Returns a list of {@link StructuredConfigProperties } configuration property.
208+ * Returns a list of {@link DeclarativeConfigProperties } configuration property.
209209 *
210210 * @return a list of map-valued configuration property, or {@code defaultValue} if {@code name}
211211 * 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
213213 */
214- default List <StructuredConfigProperties > getStructuredList (
215- String name , List <StructuredConfigProperties > defaultValue ) {
214+ default List <DeclarativeConfigProperties > getStructuredList (
215+ String name , List <DeclarativeConfigProperties > defaultValue ) {
216216 return defaultIfNull (getStructuredList (name ), defaultValue );
217217 }
218218
0 commit comments