Interface ConfigurationPropertySource
-
- All Known Subinterfaces:
AllAwareConfigurationPropertySource
- All Known Implementing Classes:
ConsumedPropertyTrackingConfigurationPropertySource
public interface ConfigurationPropertySourceA source of property values for Hibernate Search.This is effectively a key-value store, with a few features that make it convenient when retrieving configuration property values.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static ConfigurationPropertySourceempty()static AllAwareConfigurationPropertySourcefromMap(Map<String,?> map)Optional<?>get(String key)default ConfigurationPropertySourceonGet(Consumer<String> listener)Optional<String>resolve(String key)static AllAwareConfigurationPropertySourcesystem()default ConfigurationPropertySourcewithFallback(ConfigurationPropertySource fallback)Create a new configuration source which falls back to another source when a property is missing in this source.default ConfigurationPropertySourcewithMask(String mask)default ConfigurationPropertySourcewithOverride(ConfigurationPropertySource override)Create a new configuration source which overrides the properties defined in this source.default ConfigurationPropertySourcewithPrefix(String prefix)
-
-
-
Method Detail
-
get
Optional<?> get(String key)
- Parameters:
key- The key of the property to get.- Returns:
- An optional containing the value of the requested property,
or
Optional.empty()if the property is missing.
-
resolve
Optional<String> resolve(String key)
- Parameters:
key- The key of the property to get.- Returns:
- An optional containing the key as registered in the underlying configuration source,
with any transformation (
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.
-
withPrefix
default ConfigurationPropertySource withPrefix(String prefix)
- Parameters:
prefix- A prefix to prepend to configuration properties.- Returns:
- A source containing the same properties as this source, but prefixed with the given prefix plus ".".
-
withMask
default ConfigurationPropertySource withMask(String mask)
- Parameters:
mask- A mask to filter the properties with.- Returns:
- A source containing only the properties of this source that start with the given mask plus ".".
-
withFallback
default ConfigurationPropertySource withFallback(ConfigurationPropertySource fallback)
Create a new configuration source which falls back to another source when a property is missing in this source.main.withFallback( fallback )is equivalent tofallback.withOverride( main )except for one detail: in the first example, a call toresolve(String)on the resulting source will resolve the key againstmain, but in the second example it will resolve the key againstoverride.- Parameters:
fallback- A fallback source.- Returns:
- A source containing the same properties as this source, plus any property from
fallbackthat isn't in this source.
-
withOverride
default ConfigurationPropertySource withOverride(ConfigurationPropertySource override)
Create a new configuration source which overrides the properties defined in this source.main.withOverride( override )is equivalent tooverride.withFallback( main )except for one detail: in the first example, a call toresolve(String)on the resulting source will resolve the key againstmain, but in the second example it will resolve the key againstoverride.- Parameters:
override- An overriding source.- Returns:
- A source containing the same properties as this source,
overridden by the properties from
override, and augmented by the properties fromoverridethat are not in this source.
-
onGet
default ConfigurationPropertySource onGet(Consumer<String> listener)
- Parameters:
listener- A listener that will get called every timeget(String)returns a non-emptyOptional. Typically used for logging.- Returns:
- A source containing the same properties as this source, but prefixed with the given prefix plus ".".
-
fromMap
static AllAwareConfigurationPropertySource fromMap(Map<String,?> map)
-
system
static AllAwareConfigurationPropertySource system()
- Returns:
- A source containing the system properties (
System.getProperty(String)).
-
empty
static ConfigurationPropertySource empty()
- Returns:
- A source without any property.
-
-