Class ConfigurationUtils


  • public class ConfigurationUtils
    extends Object
    Utilities class for CobiGen related operations. Handles everything related to custom templates folder destination and configuration file management
    • Field Detail

      • COBIGEN_UTILITY_CLASSES_FOLDER

        public static final String COBIGEN_UTILITY_CLASSES_FOLDER
        Folder to store template utility classes in
        See Also:
        Constant Field Values
    • Constructor Detail

      • ConfigurationUtils

        public ConfigurationUtils()
    • Method Detail

      • getCustomTemplatesLocation

        public static Path getCustomTemplatesLocation()
        Checks if the configuration file exists and returns the path of the custom templates location key
        Returns:
        Path of custom templates location or null
      • getCobigenCliRootPath

        public static Path getCobigenCliRootPath()
        Returns:
        Path of Cobigen CLI root
      • getCobigenTemplatesFolderPath

        public static Path getCobigenTemplatesFolderPath()
        Checks if custom templates location path exists and either returns the path of the default location next to the CLI or the custom templates location defined in the configuration
        Returns:
        Path of Cobigen templates folder, null if the folder does not exist
      • customTemplatesLocationExists

        public static boolean customTemplatesLocationExists()
        Returns:
        boolean true if the folder specified in configuration file exists, false if not
      • createConfigFile

        public static void createConfigFile​(Path customTemplatesLocation)
                                     throws IOException
        Creates a configuration file next to the CLI executable and stores the location of the custom templates folder in it
        Parameters:
        customTemplatesLocation - File location to store in configuration file
        Throws:
        IOException - if the configuration file could not created
      • readConfigFileProperties

        public static Properties readConfigFileProperties()
        Reads the configuration file and returns all of its properties
        Returns:
        Properties
      • preprocessInputFile

        public static File preprocessInputFile​(File inputFile)
        Processes the input file's path. Strips the quotes from the file path if they are given.
        Parameters:
        inputFile - the input file
        Returns:
        input file with processed path