Package io.atomix.utils.config
Class ConfigMapper
- java.lang.Object
-
- io.atomix.utils.config.ConfigMapper
-
public class ConfigMapper extends Object
Utility for applying Typesafe configurations to Atomix configuration objects.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classConfigMapper.FieldDescriptorprotected static classConfigMapper.SetterDescriptor
-
Constructor Summary
Constructors Constructor Description ConfigMapper(ClassLoader classLoader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckRemainingProperties(Set<String> missingProperties, List<String> availableProperties, String path, Class<?> clazz)protected static Collection<ConfigMapper.FieldDescriptor>getFieldDescriptors(Class<?> type)protected ObjectgetKeyValue(Type keyType, String key)protected ObjectgetListValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, com.typesafe.config.Config config, String configPath, String configPropName)protected MapgetMapValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, com.typesafe.config.Config config, String configPath, String configPropName)protected static Collection<ConfigMapper.SetterDescriptor>getSetterDescriptors(Class<?> clazz)protected ObjectgetSetValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, com.typesafe.config.Config config, String configPath, String configPropName)protected ObjectgetValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, com.typesafe.config.Config config, String configPath, String configPropName)protected static booleanisSimpleType(Class<?> parameterClass)<T> TloadFiles(Class<T> type, List<File> files, List<String> resources)Loads the given configuration file using the mapper, falling back to the given resources.<T> TloadResources(Class<T> type, String... resources)Loads the given resources using the configuration mapper.<T> TloadResources(Class<T> type, List<String> resources)Loads the given resources using the configuration mapper.protected <T> Tmap(com.typesafe.config.Config config, Class<T> clazz)Applies the given configuration to the given type.protected <T> Tmap(com.typesafe.config.Config config, String path, String name, Class<T> clazz)Applies the given configuration to the given type.protected <T> TnewInstance(com.typesafe.config.Config config, String key, Class<T> clazz)protected static StringtoCamelCase(String originalName)protected StringtoPath(String path, String name)protected static StringtoSetterName(String name)
-
-
-
Constructor Detail
-
ConfigMapper
public ConfigMapper(ClassLoader classLoader)
-
-
Method Detail
-
loadFiles
public <T> T loadFiles(Class<T> type, List<File> files, List<String> resources)
Loads the given configuration file using the mapper, falling back to the given resources.- Type Parameters:
T- the resulting type- Parameters:
type- the type to loadfiles- the files to loadresources- the resources to which to fall back- Returns:
- the loaded configuration
-
loadResources
public <T> T loadResources(Class<T> type, String... resources)
Loads the given resources using the configuration mapper.- Type Parameters:
T- the resulting type- Parameters:
type- the type to loadresources- the resources to load- Returns:
- the loaded configuration
-
loadResources
public <T> T loadResources(Class<T> type, List<String> resources)
Loads the given resources using the configuration mapper.- Type Parameters:
T- the resulting type- Parameters:
type- the type to loadresources- the resources to load- Returns:
- the loaded configuration
-
map
protected <T> T map(com.typesafe.config.Config config, Class<T> clazz)Applies the given configuration to the given type.- Parameters:
config- the configuration to applyclazz- the class to which to apply the configuration
-
newInstance
protected <T> T newInstance(com.typesafe.config.Config config, String key, Class<T> clazz)
-
map
protected <T> T map(com.typesafe.config.Config config, String path, String name, Class<T> clazz)Applies the given configuration to the given type.- Parameters:
config- the configuration to applyclazz- the class to which to apply the configuration
-
checkRemainingProperties
protected void checkRemainingProperties(Set<String> missingProperties, List<String> availableProperties, String path, Class<?> clazz)
-
getValue
protected Object getValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, com.typesafe.config.Config config, String configPath, String configPropName)
-
getMapValue
protected Map getMapValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, com.typesafe.config.Config config, String configPath, String configPropName)
-
getSetValue
protected Object getSetValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, com.typesafe.config.Config config, String configPath, String configPropName)
-
getListValue
protected Object getListValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, com.typesafe.config.Config config, String configPath, String configPropName)
-
isSimpleType
protected static boolean isSimpleType(Class<?> parameterClass)
-
getSetterDescriptors
protected static Collection<ConfigMapper.SetterDescriptor> getSetterDescriptors(Class<?> clazz)
-
getFieldDescriptors
protected static Collection<ConfigMapper.FieldDescriptor> getFieldDescriptors(Class<?> type)
-
-