Package net.obvj.confectory.source
Interface Source<T>
-
- Type Parameters:
T- the configuration data type returned by thisSource
- All Known Implementing Classes:
AbstractSource,ClasspathFileSource,DummySource,DynamicSource,FileSource,StringSource,URLSource
public interface Source<T>The base interface for a configuration source.A
Sourceis 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 Tload(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.Tload(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- theMapperto 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 theoptionalparameter istrueand the operation fails, this method returnsnull.- Parameters:
mapper- theMapperto be applied on the source input streamoptional- 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
nullin an event of failure if theoptionalflag set astrue - Throws:
ConfigurationSourceException- in an event of failure to load the configuration source (only if theoptionalflag set asfalse)
-
-