Class AbstractConfigFactory<T extends AbstractConfig>

    • Constructor Detail

      • AbstractConfigFactory

        public AbstractConfigFactory()
    • Method Detail

      • fromProperties

        public abstract T fromProperties​(java.util.Properties props)
        Parses a configuration object from Properties.
        Parameters:
        props - the input properties
        Returns:
        the configuration object
      • fromPath

        public final T fromPath​(java.lang.String path)
                         throws java.io.IOException
        Parses a configuration object given a path.
        Parameters:
        path - the path from where to parse the configuration
        Returns:
        the configuration object
        Throws:
        java.io.IOException - if there was any I/O error during reading given path
        See Also:
        Path syntax documentation
      • fromInputStream

        public final T fromInputStream​(java.io.InputStream is,
                                       java.lang.String parentPath)
                                throws java.io.IOException
        Parses a configuration object given an input stream.
        Parameters:
        is - the input stream from where to read the configuration
        parentPath - if not null, relative paths found in config will resolved against this parentPath
        Returns:
        the configuration object
        Throws:
        java.io.IOException - if there was any I/O error during reading given input stream
      • fromInputStream

        public final T fromInputStream​(java.io.InputStream is)
                                throws java.io.IOException
        same as fromInputStream(InputStream, String), but with null passed as parentPath
        Parameters:
        is - the input stream from where to read the configuration
        Returns:
        the configuration object
        Throws:
        java.io.IOException - if there was any I/O error during reading given input stream
      • fromJson

        public final T fromJson​(java.lang.String json,
                                java.lang.String parentPath)
                         throws java.io.IOException
        Parses a configuration object given a JSON string.
        Parameters:
        json - the input JSON string
        parentPath - if not null, relative paths found in config will resolved against this parentPath
        Returns:
        the configuration object
        Throws:
        java.io.IOException - if there was any I/O error during reading given JSON string
      • fromJson

        public final T fromJson​(java.lang.String json)
                         throws java.io.IOException
        Same as fromJson(String, String), but with null passed as parentPath.
        Parameters:
        json - the input JSON string
        Returns:
        the configuration object
        Throws:
        java.io.IOException - if there was any I/O error during reading given JSON string
      • fromFile

        public final T fromFile​(java.io.File file)
                         throws java.io.IOException
        Parses a configuration object given as JSON file. Relative paths found in JSON are resolved relative to given file.
        Parameters:
        file - the input file
        Returns:
        the configuration object
        Throws:
        java.io.IOException - if there was any I/O error during reading given file
      • fromFilePath

        public final T fromFilePath​(java.lang.String path)
                             throws java.io.IOException
        Parses a configuration object given as path to a JSON file. Relative paths found in JSON are resolved relative to given file.
        Parameters:
        path - the path to the JSON file
        Returns:
        the configuration object
        Throws:
        java.io.IOException - if there was any I/O error during reading given file
      • fromProperties

        public final T fromProperties​(java.io.InputStream is)
                               throws java.io.IOException
        same as fromProperties(Properties), but instantiates a new Properties object from the given InputStream.
        Parameters:
        is - the input stream containing configuration in Properties format.
        Returns:
        the configuration object
        Throws:
        java.io.IOException - if there was any I/O error during reading given input stream