Interface RuntimeProperties
@Immutable
public interface RuntimeProperties
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic interfaceRuntimeProperties.ConfigurationBuilder<C extends RuntimeProperties, B extends RuntimeProperties.ConfigurationBuilder<C,B>> -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionasMap()Get a copy of these configuration properties as a Properties object.default PropertiesGet a copy of these configuration properties as a Properties object.static RuntimeProperties.Buildercopy(RuntimeProperties config) Create a newconfiguration builderthat starts with a copy of the supplied configuration.static RuntimeProperties.Buildercreate()Create a newconfiguration builder.default <T> voidforEach(BiConsumer<String, String> function) Call the supplied function for each of the fields.static RuntimePropertiesObtain a configuration instance by copying the supplied map of string keys and object values.static <T> RuntimePropertiesObtain a configuration instance by copying the supplied map of string keys and object values.static RuntimePropertiesfrom(Properties properties) Obtain a configuration instance by copying the supplied Properties object.default booleangetBoolean(String key, BooleanSupplier defaultValueSupplier) Get the boolean value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.default booleangetBoolean(Property property) Get the boolean value associated with the given field when that field has a default value.Get the string value associated with the given key.keys()Get the set of keys in this configuration.static RuntimePropertiesObtain a configuration instance by loading the Properties from the supplied file.static RuntimePropertiesload(InputStream stream) Obtain a configuration instance by loading the Properties from the supplied stream.static RuntimePropertiesObtain a configuration instance by loading the Properties from the supplied URL.
-
Field Details
-
PROPERTY_PREFIX
- See Also:
-
-
Method Details
-
create
Create a newconfiguration builder.- Returns:
- the configuration builder
-
copy
Create a newconfiguration builderthat starts with a copy of the supplied configuration.- Parameters:
config- the configuration to copy; may be null- Returns:
- the configuration builder
-
from
Obtain a configuration instance by copying the supplied Properties object. The suppliedPropertiesobject is copied so that the resulting Configuration cannot be modified.- Parameters:
properties- the properties; may be null or empty- Returns:
- the configuration; never null
-
from
Obtain a configuration instance by copying the supplied map of string keys and object values. The entries within the map are copied so that the resulting Configuration cannot be modified.- Parameters:
properties- the properties; may be null or empty- Returns:
- the configuration; never null
-
from
Obtain a configuration instance by copying the supplied map of string keys and object values. The entries within the map are copied so that the resulting Configuration cannot be modified.- Parameters:
properties- the properties; may be null or emptyconversion- the function that converts the supplied values into strings, or returnsnullif the value is to be excluded- Returns:
- the configuration; never null
-
load
Obtain a configuration instance by loading the Properties from the supplied URL.- Parameters:
url- the URL to the stream containing the configuration properties; may not be null- Returns:
- the configuration; never null
- Throws:
IOException- if there is an error reading the stream
-
load
Obtain a configuration instance by loading the Properties from the supplied file.- Parameters:
file- the file containing the configuration properties; may not be null- Returns:
- the configuration; never null
- Throws:
IOException- if there is an error reading the stream
-
load
Obtain a configuration instance by loading the Properties from the supplied stream.- Parameters:
stream- the stream containing the properties; may not be null- Returns:
- the configuration; never null
- Throws:
IOException- if there is an error reading the stream
-
keys
-
getString
-
getBoolean
Get the boolean value associated with the given field when that field has a default value. If the configuration does not have a name-value pair with the same name as the field, then the field's default value.- Parameters:
property- the property- Returns:
- the boolean value, or null if the key is null, there is no such key-value pair in the configuration and there is no default value in the field or the default value could not be parsed as a long, or there is a key-value pair in the configuration but the value could not be parsed as a boolean value
- Throws:
NumberFormatException- if there is no name-value pair and the field has no default value
-
getBoolean
Get the boolean value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.- Parameters:
key- the key for the configuration propertydefaultValueSupplier- the supplier for the default value; may be null- Returns:
- the boolean value, or null if the key is null, there is no such key-value pair in the configuration, the
defaultValueSupplierreference is null, or there is a key-value pair in the configuration but the value could not be parsed as a boolean value
-
asProperties
Get a copy of these configuration properties as a Properties object.- Returns:
- the properties object; never null
-
asMap
-
forEach
Call the supplied function for each of the fields.- Parameters:
function- the consumer that takes the field name and the string value extracted from the field; may not be null
-