Class DefaultConfigProperties
- java.lang.Object
-
- io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties
-
- All Implemented Interfaces:
ConfigProperties
public final class DefaultConfigProperties extends java.lang.Object implements ConfigProperties
Properties are normalized to The properties for both of these will be normalized to be all lower case, dashses are replaces with periods, and environment variable underscores are replaces with periods.This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.String>config
-
Constructor Summary
Constructors Modifier Constructor Description privateDefaultConfigProperties(DefaultConfigProperties previousProperties, java.util.Map<java.lang.String,java.lang.String> overrides)privateDefaultConfigProperties(java.util.Map<?,?> systemProperties, java.util.Map<java.lang.String,java.lang.String> environmentVariables, java.util.Map<java.lang.String,java.lang.String> defaultProperties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DefaultConfigPropertiescreate(java.util.Map<java.lang.String,java.lang.String> defaultProperties)Creates aDefaultConfigPropertiesby merging system properties, environment variables, and thedefaultProperties.static DefaultConfigPropertiescreateFromMap(java.util.Map<java.lang.String,java.lang.String> properties)Create aDefaultConfigPropertiesfrom theproperties, ignoring system properties and environment variables.private static java.util.List<java.lang.String>filterBlanksAndNulls(java.lang.String[] values)java.lang.BooleangetBoolean(java.lang.String name)Returns a boolean-valued configuration property.java.lang.DoublegetDouble(java.lang.String name)Returns a double-valued configuration property.java.time.DurationgetDuration(java.lang.String name)Returns a duration property from the map, ornullif it cannot be found or it has a wrong type.private static java.util.concurrent.TimeUnitgetDurationUnit(java.lang.String unitString)Returns the TimeUnit associated with a unit string.java.lang.IntegergetInt(java.lang.String name)Returns an Integer-valued configuration property.java.util.List<java.lang.String>getList(java.lang.String name)Returns a list-valued configuration property.java.lang.LonggetLong(java.lang.String name)Returns a Long-valued configuration property.java.util.Map<java.lang.String,java.lang.String>getMap(java.lang.String name)Returns a Map configuration property.static java.util.Set<java.lang.String>getSet(ConfigProperties config, java.lang.String name)ReturnsConfigProperties.getList(String)as aSetafter validating there are no duplicate entries.java.lang.StringgetString(java.lang.String name)Returns a string-valued configuration property.private static java.lang.StringgetUnitString(java.lang.String rawValue)Fragments the 'units' portion of a config value from the 'value' portion.private static ConfigurationExceptionnewInvalidPropertyException(java.lang.String name, java.lang.String value, java.lang.String type)DefaultConfigPropertieswithOverrides(java.util.Map<java.lang.String,java.lang.String> overrides)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties
getBoolean, getDouble, getDuration, getInt, getList, getLong, getMap, getString
-
-
-
-
Constructor Detail
-
DefaultConfigProperties
private DefaultConfigProperties(java.util.Map<?,?> systemProperties, java.util.Map<java.lang.String,java.lang.String> environmentVariables, java.util.Map<java.lang.String,java.lang.String> defaultProperties)
-
DefaultConfigProperties
private DefaultConfigProperties(DefaultConfigProperties previousProperties, java.util.Map<java.lang.String,java.lang.String> overrides)
-
-
Method Detail
-
create
public static DefaultConfigProperties create(java.util.Map<java.lang.String,java.lang.String> defaultProperties)
Creates aDefaultConfigPropertiesby merging system properties, environment variables, and thedefaultProperties.Environment variables take priority over
defaultProperties. System properties take priority over environment variables.
-
createFromMap
public static DefaultConfigProperties createFromMap(java.util.Map<java.lang.String,java.lang.String> properties)
Create aDefaultConfigPropertiesfrom theproperties, ignoring system properties and environment variables.
-
getString
@Nullable public java.lang.String getString(java.lang.String name)
Description copied from interface:ConfigPropertiesReturns a string-valued configuration property.- Specified by:
getStringin interfaceConfigProperties- Returns:
- null if the property has not been configured.
-
getBoolean
@Nullable public java.lang.Boolean getBoolean(java.lang.String name)
Description copied from interface:ConfigPropertiesReturns a boolean-valued configuration property. Implementations should use the same rules asBoolean.parseBoolean(String)for handling the values.- Specified by:
getBooleanin interfaceConfigProperties- Returns:
- null if the property has not been configured.
-
getInt
@Nullable public java.lang.Integer getInt(java.lang.String name)
Description copied from interface:ConfigPropertiesReturns an Integer-valued configuration property.- Specified by:
getIntin interfaceConfigProperties- Returns:
- null if the property has not been configured.
-
getLong
@Nullable public java.lang.Long getLong(java.lang.String name)
Description copied from interface:ConfigPropertiesReturns a Long-valued configuration property.- Specified by:
getLongin interfaceConfigProperties- Returns:
- null if the property has not been configured.
-
getDouble
@Nullable public java.lang.Double getDouble(java.lang.String name)
Description copied from interface:ConfigPropertiesReturns a double-valued configuration property.- Specified by:
getDoublein interfaceConfigProperties- Returns:
- null if the property has not been configured.
-
getDuration
@Nullable public java.time.Duration getDuration(java.lang.String name)
Description copied from interface:ConfigPropertiesReturns a duration property from the map, ornullif it cannot be found or it has a wrong type.Durations can be of the form "{number}{unit}", where unit is one of:
- ms
- s
- m
- h
- d
If no unit is specified, milliseconds is the assumed duration unit.
- Specified by:
getDurationin interfaceConfigProperties- Parameters:
name- The property name- Returns:
- the
Durationvalue of the property,nullif the property cannot be found.
-
getList
public java.util.List<java.lang.String> getList(java.lang.String name)
Description copied from interface:ConfigPropertiesReturns a list-valued configuration property. The format of the original value must be comma-separated. Empty values will be removed.- Specified by:
getListin interfaceConfigProperties- Returns:
- an empty list if the property has not been configured.
-
getSet
public static java.util.Set<java.lang.String> getSet(ConfigProperties config, java.lang.String name)
ReturnsConfigProperties.getList(String)as aSetafter validating there are no duplicate entries.- Throws:
ConfigurationException- ifnamecontains duplicate entries
-
getMap
public java.util.Map<java.lang.String,java.lang.String> getMap(java.lang.String name)
Description copied from interface:ConfigPropertiesReturns a Map configuration property. The format of the original value must be comma-separated for each key, with an '=' separating the key and value. For instance,service.name=Greatest Service,host.name=localhost. Empty values will be removed.- Specified by:
getMapin interfaceConfigProperties- Returns:
- an empty map if the property has not been configured.
-
withOverrides
public DefaultConfigProperties withOverrides(java.util.Map<java.lang.String,java.lang.String> overrides)
-
newInvalidPropertyException
private static ConfigurationException newInvalidPropertyException(java.lang.String name, java.lang.String value, java.lang.String type)
-
filterBlanksAndNulls
private static java.util.List<java.lang.String> filterBlanksAndNulls(java.lang.String[] values)
-
getDurationUnit
private static java.util.concurrent.TimeUnit getDurationUnit(java.lang.String unitString)
Returns the TimeUnit associated with a unit string. Defaults to milliseconds.
-
getUnitString
private static java.lang.String getUnitString(java.lang.String rawValue)
Fragments the 'units' portion of a config value from the 'value' portion.E.g. "1ms" would return the string "ms".
-
-