io.scalecube.config.ConfigRegistry Maven / Gradle / Ivy
package io.scalecube.config;
import io.scalecube.config.audit.ConfigEvent;
import io.scalecube.config.source.ConfigSourceInfo;
import java.time.Duration;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
/**
* Config registry base facade interface.
*
* @author Anton Kharenko
*/
public interface ConfigRegistry {
/**
* Creates new instance of config registry with the given settings.
*
* @param settings config registry settings
* @return config registry instance
*/
static ConfigRegistry create(ConfigRegistrySettings settings) {
ConfigRegistryImpl configRegistry = new ConfigRegistryImpl(settings);
configRegistry.init();
return configRegistry;
}
/**
* Returns dynamic typed object property.
*
* @param prefix prefix of property keys extended with field names as prefix.fieldName to resolve
* full property keys
* @param cfgClass a class of config object instance
* @param a type of config object
* @return property instance
*/
ObjectConfigProperty objectProperty(String prefix, Class cfgClass);
/**
* Returns dynamic typed object property.
*
* @param bindingMap custom mapping between class field names and property names
* @param cfgClass a class of config object instance
* @param a type of config object
* @return property instance
*/
ObjectConfigProperty objectProperty(Map bindingMap, Class cfgClass);
/**
* Returns dynamic typed object property.
*
* @param name property name
* @param mapper which transform the given property value to the given class instance
* @param a type of config object
* @return property instance
*/
ObjectConfigProperty objectProperty(String name, Function mapper);
/**
* Returns dynamic typed object property. Package name of the class comes as prefix.
*
* @param cfgClass a class of config object instance
* @param a type of config object
* @return property instance
*/
ObjectConfigProperty objectProperty(Class cfgClass);
/**
* Returns current value of object property or defaults.
*
* @param cfgClass a class of config object instance
* @param defaultValue default config object
* @param a type of returned config object
* @return property value
*/
T objectValue(String prefix, Class cfgClass, T defaultValue);
/**
* Returns current value of object property or defaults.
*
* @param bindingMap custom mapping between class field names and property names
* @param cfgClass a class of config object instance
* @param defaultValue default config object
* @param a type of returned config object
* @return property value
*/
T objectValue(Map bindingMap, Class cfgClass, T defaultValue);
/**
* Returns current value of object property or defaults. Package name of the class comes as
* prefix.
*
* @param cfgClass a class of config object instance
* @param defaultValue default config object
* @param a type of returned config object
* @return property value
*/
T objectValue(Class cfgClass, T defaultValue);
/**
* Returns dynamic typed string property. String property is a base type for all properties and
* each type can be casted to string property.
*
* @param name property name
* @return property instance
*/
StringConfigProperty stringProperty(String name);
/**
* Returns current value of string property or defaults.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
String stringValue(String name, String defaultValue);
/**
* Returns dynamic typed double property.
*
* @param name property name
* @return property instance
*/
DoubleConfigProperty doubleProperty(String name);
/**
* Returns current value of double property or defaults.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
double doubleValue(String name, double defaultValue);
/**
* Returns dynamic typed long property.
*
* @param name property name
* @return property instance
*/
LongConfigProperty longProperty(String name);
/**
* Returns current value of long property or defaults.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
long longValue(String name, long defaultValue);
/**
* Returns dynamic typed boolean property.
*
* @param name property name
* @return property instance
*/
BooleanConfigProperty booleanProperty(String name);
/**
* Returns current value of boolean property or defaults.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
boolean booleanValue(String name, boolean defaultValue);
/**
* Returns dynamic typed integer property.
*
* @param name property name
* @return property instance
*/
IntConfigProperty intProperty(String name);
/**
* Returns current value of int property or defaults.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
int intValue(String name, int defaultValue);
/**
* Returns dynamic typed java8 duration property. See for details {@link
* Duration#parse(java.lang.CharSequence)}.
*
* @param name property name
* @return property instance
*/
DurationConfigProperty durationProperty(String name);
/**
* Returns current value of java8 duration property or defaults. See for details {@link
* Duration#parse(java.lang.CharSequence)}.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
Duration durationValue(String name, Duration defaultValue);
/**
* Returns dynamic generic-typed list property.
*
* @param name property name
* @return property instance
*/
ListConfigProperty stringListProperty(String name);
/**
* Returns current value of list property or defaults.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
List stringListValue(String name, List defaultValue);
/**
* Returns dynamic generic-typed list property.
*
* @param name property name
* @return property instance
*/
ListConfigProperty doubleListProperty(String name);
/**
* Returns current value of list property or defaults.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
List doubleListValue(String name, List defaultValue);
/**
* Returns dynamic generic-typed list property.
*
* @param name property name
* @return property instance
*/
ListConfigProperty longListProperty(String name);
/**
* Returns current value of list property or defaults.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
List longListValue(String name, List defaultValue);
/**
* Returns dynamic generic-typed list property.
*
* @param name property name
* @return property instance
*/
ListConfigProperty intListProperty(String name);
/**
* Returns current value of list property or defaults.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
List intListValue(String name, List defaultValue);
/**
* Returns dynamic generic-typed list property.
*
* @param name property name
* @return property instance
*/
ListConfigProperty durationListProperty(String name);
/**
* Returns current value of list property or defaults.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
List durationListValue(String name, List defaultValue);
/**
* Returns dynamic generic-typed multimap property.
*
* @param name property name
* @return property instance
*/
MultimapConfigProperty stringMultimapProperty(String name);
/**
* Returns current value of multimap property or defaults.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
Map> stringMultimapValue(
String name, Map> defaultValue);
/**
* Returns dynamic generic-typed multimap property.
*
* @param name property name
* @return property instance
*/
MultimapConfigProperty doubleMultimapProperty(String name);
/**
* Returns current value of multimap property or defaults.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
Map> doubleMultimapValue(
String name, Map> defaultValue);
/**
* Returns dynamic generic-typed multimap property.
*
* @param name property name
* @return property instance
*/
MultimapConfigProperty longMultimapProperty(String name);
/**
* Returns current value of multimap property or defaults.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
Map> longMultimapValue(String name, Map> defaultValue);
/**
* Returns dynamic generic-typed multimap property.
*
* @param name property name
* @return property instance
*/
MultimapConfigProperty intMultimapProperty(String name);
/**
* Returns current value of multimap property or defaults.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
Map> intMultimapValue(String name, Map> defaultValue);
/**
* Returns dynamic generic-typed multimap property.
*
* @param name property name
* @return property instance
*/
MultimapConfigProperty durationMultimapProperty(String name);
/**
* Returns current value of multimap property or defaults.
*
* @param name property name
* @param defaultValue default property value
* @return property value
*/
Map> durationMultimapValue(
String name, Map> defaultValue);
/** Returns set of all loaded property keys. */
Set allProperties();
/** Returns snapshot of all current property values. */
Collection getConfigProperties();
/** Returns list of recent property changes events. */
Collection getRecentConfigEvents();
/** Returns list of configured property sources descriptions. */
Collection getConfigSources();
/** Returns config registry settings. */
ConfigRegistrySettings getSettings();
}