Interface Source<T>

  • Type Parameters:
    T - the configuration data type returned by this Source
    All Known Implementing Classes:
    AbstractSource, ClasspathFileSource, DummySource, DynamicSource, FileSource, StringSource, URLSource

    public interface Source<T>
    The base interface for a configuration source.

    A Source is an object that basically defines the configuration input (e.g.: file, URL) and contains built-in logic for data access.

    Since:
    0.1.0
    Author:
    oswaldo.bapvic.jr (Oswaldo Junior)
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      T load​(Mapper<T> mapper)
      Applies a specific configuration loading strategy and returns a mapped bean containing the retrieved data, throwing an exception if the operation fails.
      T load​(Mapper<T> mapper, boolean optional)
      Applies a specific configuration loading strategy and returns a mapped bean containing the retrieved data.
    • Method Detail

      • load

        T load​(Mapper<T> mapper)
        Applies a specific configuration loading strategy and returns a mapped bean containing the retrieved data, throwing an exception if the operation fails.
        Parameters:
        mapper - the Mapper to be applied on the source input stream
        Returns:
        the loaded configuration data
        Throws:
        ConfigurationSourceException - in an event of failure to load the configuration source
      • load

        T load​(Mapper<T> mapper,
               boolean optional)
        Applies a specific configuration loading strategy and returns a mapped bean containing the retrieved data. If the optional parameter is true and the operation fails, this method returns null.
        Parameters:
        mapper - the Mapper to be applied on the source input stream
        optional - a flag indicating whether or not an exception should be thrown in an event of failure to load the configuration source
        Returns:
        the loaded configuration data, or null in an event of failure if the optional flag set as true
        Throws:
        ConfigurationSourceException - in an event of failure to load the configuration source (only if the optional flag set as false)