Skip to content

Instantly share code, notes, and snippets.

@rhusar
Created October 9, 2019 14:07
Show Gist options
  • Save rhusar/40ae442de70dba3abf1d37f4513c0060 to your computer and use it in GitHub Desktop.
Save rhusar/40ae442de70dba3abf1d37f4513c0060 to your computer and use it in GitHub Desktop.
@org.osgi.annotation.versioning.ProviderType
public interface Config {
/**
* Return the resolved property value with the specified type for the
* specified property name from the underlying {@link ConfigSource ConfigSources}.
*
* If this method gets used very often then consider to locally store the configured value.
*
* @param <T>
* The property type
* @param propertyName
* The configuration propertyName.
* @param propertyType
* The type into which the resolve property value should get converted
* @return the resolved property value as an object of the requested type.
* @throws java.lang.IllegalArgumentException if the property cannot be converted to the specified type.
* @throws java.util.NoSuchElementException if the property isn't present in the configuration.
*/
<T> T getValue(String propertyName, Class<T> propertyType);
/**
* Return the resolved property value with the specified type for the
* specified property name from the underlying {@link ConfigSource ConfigSources}.
*
* If this method is used very often then consider to locally store the configured value.
*
* @param <T>
* The property type
* @param propertyName
* The configuration propertyName.
* @param propertyType
* The type into which the resolve property value should be converted
* @return The resolved property value as an Optional of the requested type.
*
* @throws java.lang.IllegalArgumentException if the property cannot be converted to the specified type.
*/
<T> Optional<T> getOptionalValue(String propertyName, Class<T> propertyType);
/**
* Return a collection of property names.
* @return the names of all configured keys of the underlying configuration.
*/
Iterable<String> getPropertyNames();
/**
* @return all currently registered {@link ConfigSource configsources} sorted with descending ordinal and ConfigSource name
*/
Iterable<ConfigSource> getConfigSources();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment