-
Notifications
You must be signed in to change notification settings - Fork 1
Using the API
The API offers interfaces for loaders (IConfigLoader
), serializers (IConfigSerializer
), configuration nodes (IConfigNode
) and whole configuration (IConfig
) abstractions.
Configuration loaders can be retrieved by the LoaderFactory
using the #getLoader(String)
method which takes file extensions or mime types as defined by the respective loaders @FormatRef
annotation.
Configuration loaders can parse InputStream
s into instances of IConfigNode
.
Instances of IConfig
need to be constructed manually. As of now, the FileConfig
is available for configurations loaded from java.io.File
instances. It is recommended that the controlling part of an application takes care of instantiation of IConfig
objects then passing them on to the consuming part of the code as IConfig
s.
Configurations will be deserialized into tree-like structures made of config nodes which are all IValueHolders
and thus can carry different values. The value of a configuration node can be extracted using the different API methods on IConfigNode
and its super interfaces. (Please see their javadoc comments in the sources jar artifact!)
A configuration node can be:
- A map of
String -> IConfigNode
- A list of
IConfigNode
- A primitive value (
Integer
,Float
,Double
,Boolean
) - A string
- A virtual configuration node meaning that no value is stored and the node will not be serialized.
The tree below a configuration node can be traversed using the #getNode(String...)
method which will always return a non-null configuration node that will be virtual should the path not exist in the configuration.