Class ConfigurationUtils

java.lang.Object
org.brapi.schematools.core.utils.ConfigurationUtils

public class ConfigurationUtils extends Object
Utility class for loading configuration files.
  • Constructor Details

    • ConfigurationUtils

      public ConfigurationUtils()
  • Method Details

    • load

      public static <T> T load(Path configurationsFile, Class<T> configurationClass) throws IOException
      Load the configurations from a file in YAML or Json.
      Type Parameters:
      T - the class of the configuration
      Parameters:
      configurationsFile - The path to the configuration file in YAML or Json.
      configurationClass - The configuration class.
      Returns:
      The configurations loaded from the YAML or Json file.
      Throws:
      IOException - if the file can not be found or is incorrectly formatted.
    • load

      public static <T> T load(String classPath, Class<T> configurationClass) throws IOException
      Load the default configurations from the classpath
      Type Parameters:
      T - the class of the configuration
      Parameters:
      classPath - The class path on which the configuration file can be found
      configurationClass - The configuration class.
      Returns:
      The default configurations
      Throws:
      IOException - if the file can not be found or is incorrectly formatted.
    • load

      public static <T> T load(InputStream inputStream, Class<T> configurationClass) throws IOException
      Load the configurations from an input stream in YAML or Json.
      Type Parameters:
      T - the class of the configuration
      Parameters:
      inputStream - The input stream in YAML or Json
      configurationClass - The configuration class.
      Returns:
      The configurations loaded from input stream.
      Throws:
      IOException - if the input stream is not valid or the content is incorrectly formatted.