Class ConfigMergeUtility


  • public class ConfigMergeUtility
    extends java.lang.Object
    The type Config merge utility.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T getConfigByMerge​(java.lang.String configFile, java.lang.String customFile, java.lang.String folder, java.lang.Class<T> clazz, java.lang.Class<?>[] clazzArray)
      Gets config with optional custom config merge.
      static <T> T getConfigByName​(java.lang.String folder, java.lang.String fileName, java.lang.Class<T> clazz, java.lang.Class<?>[] clazzArray)
      Gets one config class.
      static java.util.List<PluginConfig> getPluginConfigsFromFolder​(java.lang.String folder, java.lang.Class<?>... customClazz)
      Gets all configurations from given folder.
      static <T> T mergeConfigs​(T config, T customConfig)
      Merges a first (default) configuration with a second (custom) configuration.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getPluginConfigsFromFolder

        public static final java.util.List<PluginConfig> getPluginConfigsFromFolder​(java.lang.String folder,
                                                                                    java.lang.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​(java.lang.String folder,
                                                  java.lang.String fileName,
                                                  java.lang.Class<T> clazz,
                                                  java.lang.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​(java.lang.String configFile,
                                                   java.lang.String customFile,
                                                   java.lang.String folder,
                                                   java.lang.Class<T> clazz,
                                                   java.lang.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 MergableConfig interface.

        Type Parameters:
        T - the type parameter
        Parameters:
        config - the config
        customConfig - the custom config
        Returns:
        merged configuration