Package com.priint.pubserver.config
Class ConfigMergeUtility
java.lang.Object
com.priint.pubserver.config.ConfigMergeUtility
The type Config merge utility.
-
Method Summary
Modifier and TypeMethodDescriptionstatic final <T> TgetConfigByMerge(String configFile, String customFile, String folder, Class<T> clazz, Class<?>[] clazzArray) Gets config with optional custom config merge.static final <T> TgetConfigByName(String folder, String fileName, Class<T> clazz, Class<?>[] clazzArray) Gets one config class.static final List<PluginConfig>getPluginConfigsFromFolder(String folder, Class<?>... customClazz) Gets all configurations from given folder.static final <T> TmergeConfigs(T config, T customConfig) Merges a first (default) configuration with a second (custom) configuration.
-
Method Details
-
getPluginConfigsFromFolder
public static final List<PluginConfig> getPluginConfigsFromFolder(String folder, Class<?>... customClazz) Gets all configurations from given folder.- Parameters:
folder- Path to configurations.customClazz- Class of config.- Returns:
- List of config classes.
-
getConfigByName
public static final <T> T getConfigByName(String folder, String fileName, Class<T> clazz, Class<?>[] clazzArray) Gets one config class.- Type Parameters:
T- the type parameter- Parameters:
folder- Path to config file.fileName- Name of config file.clazz- Class of config.clazzArray- Array of classes of configurations. Can be set to null.- Returns:
- One config class.
-
getConfigByMerge
public static final <T> T getConfigByMerge(String configFile, String customFile, String folder, Class<T> clazz, Class<?>[] clazzArray) Gets config with optional custom config merge. If given file does not exist, this method returns just base config class and behave exactly like (#getConfigByName(String, String, Class).- Type Parameters:
T- the type parameter- Parameters:
configFile- Name of base config file.customFile- Name of custom config file, which will be merged to base config file.folder- Path to base and custom config files.clazz- Class of configurations.clazzArray- the clazz array- Returns:
- If custom config is available, method returns merged configurations as one config. If custom config is not available, method returns only base config.
-
mergeConfigs
public static final <T> T mergeConfigs(T config, T customConfig) Merges a first (default) configuration with a second (custom) configuration. If settings are defined in the second configuration they will override the settings of the first.Configuration class must implement the
MergableConfiginterface.- Type Parameters:
T- the type parameter- Parameters:
config- the configcustomConfig- the custom config- Returns:
- merged configuration
-