public interface ConfigurationPropertySource
Modifier and Type | Method and Description |
---|---|
static ConfigurationPropertySource |
empty() |
static ConfigurationPropertySource |
fromMap(Map<String,?> map) |
static ConfigurationPropertySource |
fromProperties(Properties properties)
Deprecated.
Where possible, use
fromMap(Map) instead, which supports non-string values. |
Optional<?> |
get(String key) |
Optional<String> |
resolve(String key) |
default ConfigurationPropertySource |
withFallback(ConfigurationPropertySource fallback)
Create a new configuration source which falls back to another source when a property is missing in this source.
|
default ConfigurationPropertySource |
withMask(String mask) |
default ConfigurationPropertySource |
withOverride(ConfigurationPropertySource override)
Create a new configuration source which overrides the properties defined in this source.
|
default ConfigurationPropertySource |
withPrefix(String prefix) |
Optional<?> get(String key)
key
- The key of the property to get.Optional.empty()
if the property is missing.Optional<String> resolve(String key)
key
- The key of the property to get.prefixes
, masks
)
reverted.
Whether the optional is empty is not related to the key having a value in the underlying configuration source;
instead, the optional is empty only if the key cannot possibly be registered in the underlying configuration source,
e.g. if the key is missing a mandatory prefix.default ConfigurationPropertySource withPrefix(String prefix)
prefix
- A prefix to prepend to configuration properties.default ConfigurationPropertySource withMask(String mask)
mask
- A mask to filter the properties with.default ConfigurationPropertySource withFallback(ConfigurationPropertySource fallback)
main.withFallback( fallback )
is equivalent to fallback.withOverride( main )
except for one detail: in the first example, a call to resolve(String)
on the resulting source
will resolve the key against main
, but in the second example it will resolve the key against override
.
fallback
- A fallback source.fallback
that isn't in this source.default ConfigurationPropertySource withOverride(ConfigurationPropertySource override)
main.withOverride( override )
is equivalent to override.withFallback( main )
except for one detail: in the first example, a call to resolve(String)
on the resulting source
will resolve the key against main
, but in the second example it will resolve the key against override
.
override
- An overriding source.override
,
and augmented by the properties from override
that are not in this source.static ConfigurationPropertySource fromMap(Map<String,?> map)
@Deprecated static ConfigurationPropertySource fromProperties(Properties properties)
fromMap(Map)
instead, which supports non-string values.properties
- The Properties
object to extract property values from.Properties
object.static ConfigurationPropertySource empty()
Copyright © 2006-2019 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.