Interface ConfigResolver
- All Known Implementing Classes:
ConfigResolverImpl
Should be used for implementing new configuration types
- Since:
- 2.0.0
- Author:
- MrIvanPlays
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
default void
dump
(Object annotatedConfig, OutputStream os) void
void
void
Loads the specifiedannotatedConfig
from the specifiedFile
file
using the defaultSettings
from the builder of this config resolver, orACDefaultSettings.getDefault()
.void
default void
load
(Object annotatedConfig, InputStream in) Loads the specifiedannotatedConfig
from the specifiedInputStream
in
the defaultSettings
from the builder of this config resolver, orACDefaultSettings.getDefault()
.default void
load
(Object annotatedConfig, InputStream in, Settings settings) Loads the specifiedannotatedConfig
from the specifiedInputStream
in
using theSettings
settings
specified.void
Loads the specifiedannotatedConfig
from the specifiedReader
reader
the defaultSettings
from the builder of this config resolver, orACDefaultSettings.getDefault()
.void
void
Loads the specifiedannotatedConfig
from the specifiedPath
path
using the defaultSettings
from the builder of this config resolver, orACDefaultSettings.getDefault()
.void
void
Loads the specifiedannotatedConfig
from the specifiedMap
values
using the defaultSettings
from the builder of this config resolver, orACDefaultSettings.getDefault()
.void
void
loadOrDump
(Object annotatedConfig, File file) Loads the specifiedannotatedConfig
from the specifiedFile
file
, if it exists, if not, dumps the specifiedannotatedConfig
to the specified file, using the defaultSettings
from the builder of this config resolver, orACDefaultSettings.getDefault()
.void
loadOrDump
(Object annotatedConfig, File file, Settings settings) void
loadOrDump
(Object annotatedConfig, Path path) Loads the specifiedannotatedConfig
from the specifiedPath
path
, if it exists, if not, dumps the specifiedannotatedConfig
to the specified file, using the defaultSettings
from the builder of this config resolver, orACDefaultSettings.getDefault()
.void
loadOrDump
(Object annotatedConfig, Path path, Settings settings) static ConfigResolver.Builder
Creates a newConfigResolver.Builder
resolveMultiple
(File dir, Supplier<T> configToResolveTo, WritableObject dumpFile) Loads the configurations in theFile
dir
specified, and if any do not exist, the defaults (if specified) are dumped to the specifiedWritableObject
dumpFile
.resolveMultiple
(File dir, Supplier<T> configToResolveTo, WritableObject dumpFile, Settings settings) Loads the configurations in theFile
dir
specified, and if any do not exist, the defaults (if specified) are dumped to the specifiedWritableObject
dumpFile
.resolveMultiple
(Path dir, Supplier<T> configToResolveTo, WritableObject dumpFile) Loads the configurations in thePath
dir
specified, and if any do not exist, the defaults (if specified) are dumped to the specifiedWritableObject
dumpFile
.resolveMultiple
(Path dir, Supplier<T> configToResolveTo, WritableObject dumpFile, Settings settings) Loads the configurations in thePath
dir
specified, and if any do not exist, the defaults (if specified) are dumped to the specifiedWritableObject
dumpFile
.settings()
Returns theSettings
instance held by this config resolver.
-
Method Details
-
newBuilder
Creates a newConfigResolver.Builder
- Returns:
- new builder
-
settings
Returns theSettings
instance held by this config resolver.- Returns:
- settings
- See Also:
-
dump
Dumps the specifiedannotatedConfig
to the specifiedFile
file
. If, at the time of calling this method, the file exists, it will get deleted ( default implementation ).If you are going to call
load(Object, File, Settings)
after calling this method, consider usingloadOrDump(Object, File, Settings)
rather than calling dump and load one after each other. This way you save CPU time by not making the library find annotations twice.- Parameters:
annotatedConfig
- the annotated config you want to dumpfile
- the file you want to dump the annotated config to
-
dump
Dumps the specifiedannotatedConfig
to the specifiedPath
path
. If, at the time of calling this method, the file exists, it will get deleted ( default implementation ).If you are going to call
load(Object, Path, Settings)
after calling this method, consider usingloadOrDump(Object, Path, Settings)
rather than calling dump and load one after each other. This way you save CPU time by not making the library find annotations twice.- Parameters:
annotatedConfig
- the annotated config you want to dumppath
- the file path you want to dump the annotation config to
-
dump
- Parameters:
annotatedConfig
- the annotated config you want to dumpos
- the output stream to dump the annotated config to
-
dump
- Parameters:
annotatedConfig
- the annotated config you want to dumpwriter
- the writer to dump the annotated config to
-
load
Loads the specifiedannotatedConfig
from the specifiedFile
file
using the defaultSettings
from the builder of this config resolver, orACDefaultSettings.getDefault()
.If you have called
dump(Object, File)
before calling this method, consider usingloadOrDump(Object, File)
rather than calling dump and load one after each other. This way you save CPU time by not making the library find annotations twice.- Parameters:
annotatedConfig
- the annotated config you want to load tofile
- the file you want to load
-
load
Loads the specifiedannotatedConfig
from the specifiedPath
path
using the defaultSettings
from the builder of this config resolver, orACDefaultSettings.getDefault()
.If you have called
dump(Object, Path)
before calling this method, consider usingloadOrDump(Object, Path)
rather than calling dump and load one after each other. This way you save CPU time by not making the library find annotations twice.- Parameters:
annotatedConfig
- the annotated config you want to load topath
- the file path you want to load
-
load
Loads the specifiedannotatedConfig
from the specifiedFile
file
using theSettings
settings
specified.If you have called
dump(Object, File)
before calling this method, consider usingloadOrDump(Object, File, Settings)
rather than calling dump and load one after each other. This way you save CPU time by not making the library find annotations twice.- Parameters:
annotatedConfig
- the annotated config you want to load tofile
- the file you want to loadsettings
- the load settings
-
load
Loads the specifiedannotatedConfig
from the specifiedPath
path
using theSettings
settings
specified.If you have called
dump(Object, Path)
before calling this method, consider usingloadOrDump(Object, Path, Settings)
rather than calling dump and load one after each other. This way you save CPU time by not making the library find annotations twice.- Parameters:
annotatedConfig
- the annotated config you want to load topath
- the file path you want to loadsettings
- the load settings
-
load
Loads the specifiedannotatedConfig
from the specifiedMap
values
using the defaultSettings
from the builder of this config resolver, orACDefaultSettings.getDefault()
.- Parameters:
annotatedConfig
- the annotated config you want to load tovalues
- the values you want to load
-
load
Loads the specifiedannotatedConfig
from the specifiedMap
values
using theSettings
settings
specified.- Parameters:
annotatedConfig
- the annotated you config you want to load tovalues
- the values you want to loadsettings
- the load settings
-
load
Loads the specifiedannotatedConfig
from the specifiedInputStream
in
the defaultSettings
from the builder of this config resolver, orACDefaultSettings.getDefault()
.If you have a
File
orPath
instance before calling that, consider usingload(Object, File)
. This way you allow AnnotatedConfig to generate missing options if the load settings allow it.- Parameters:
annotatedConfig
- the annotated config you want to load toin
- the input stream you want to load
-
load
Loads the specifiedannotatedConfig
from the specifiedInputStream
in
using theSettings
settings
specified.If you have a
File
orPath
instance before calling that, consider usingload(Object, File, Settings)
. This way you allow AnnotatedConfig to generate missing options if the load settings allow it.- Parameters:
annotatedConfig
- the annotated config you want to load toin
- the input stream you want to loadsettings
- the load settings
-
load
Loads the specifiedannotatedConfig
from the specifiedReader
reader
the defaultSettings
from the builder of this config resolver, orACDefaultSettings.getDefault()
.If you have a
File
orPath
instance before calling that, consider usingload(Object, File)
. This way you allow AnnotatedConfig to generate missing options if the load settings allow it.- Parameters:
annotatedConfig
- the annotated config you want to load toreader
- the reader you want to load
-
load
Loads the specifiedannotatedConfig
from the specifiedReader
reader
using theSettings
settings
specified.If you have a
File
orPath
instance before calling that, consider usingload(Object, File, Settings)
. This way you allow AnnotatedConfig to generate missing options if the load settings allow it.- Parameters:
annotatedConfig
- the annotated config you want to load toreader
- the reader you want to loadsettings
- the load settings
-
loadOrDump
Loads the specifiedannotatedConfig
from the specifiedFile
file
, if it exists, if not, dumps the specifiedannotatedConfig
to the specified file, using the defaultSettings
from the builder of this config resolver, orACDefaultSettings.getDefault()
.- Parameters:
annotatedConfig
- the annotated config you want to load/dumpfile
- the file you want to load/dump to
-
loadOrDump
Loads the specifiedannotatedConfig
from the specifiedPath
path
, if it exists, if not, dumps the specifiedannotatedConfig
to the specified file, using the defaultSettings
from the builder of this config resolver, orACDefaultSettings.getDefault()
.- Parameters:
annotatedConfig
- the annotated config you want to load/dumppath
- the file path you want to load/dump to
-
loadOrDump
Loads the specifiedannotatedConfig
from the specifiedFile
file
, if it exists, if not, dumps the specifiedannotatedConfig
to the specified file, using theSettings
settings
specified.- Parameters:
annotatedConfig
- the annotated config you want to load/dumpfile
- the file you want to load/dump tosettings
- the load settings
-
loadOrDump
Loads the specifiedannotatedConfig
from the specifiedPath
path
, if it exists, if not, dumps the specifiedannotatedConfig
to the specified file, using theSettings
settings
specified.- Parameters:
annotatedConfig
- the annotated config you want to load/dumppath
- the file path you want to load/dump tosettings
- the load settings
-
resolveMultiple
Loads the configurations in theFile
dir
specified, and if any do not exist, the defaults (if specified) are dumped to the specifiedWritableObject
dumpFile
.
WARNING: The specifiedFile
dir
has to be a directory!!!!!- Type Parameters:
T
- configuration type needed- Parameters:
dir
- the directory to load configurations fromconfigToResolveTo
- aSupplier
of the needed configuration objectsdumpFile
- the default dump file- Returns:
- a map of the loaded configurations, key being the file name. If the map is empty then AnnotationConfig couldn't find any configurations in the folder, and you should fall back to the defaults.
- Throws:
IllegalArgumentException
- if the specifieddir
is not a directory!
-
resolveMultiple
<T> Map<String,T> resolveMultiple(File dir, Supplier<T> configToResolveTo, WritableObject dumpFile, Settings settings) Loads the configurations in theFile
dir
specified, and if any do not exist, the defaults (if specified) are dumped to the specifiedWritableObject
dumpFile
.
WARNING: The specifiedFile
dir
has to be a directory!!!!!- Type Parameters:
T
- configuration type needed- Parameters:
dir
- the directory to load configurations fromconfigToResolveTo
- aSupplier
of the needed configuration objectsdumpFile
- the default dump filesettings
- the load settings to use when loading the configurations- Returns:
- a map of the loaded configurations, key being the file name. If the map is empty then AnnotationConfig couldn't find any configurations in the folder, and you should fall back to the defaults.
- Throws:
IllegalArgumentException
- if the specifieddir
is not a directory!
-
resolveMultiple
Loads the configurations in thePath
dir
specified, and if any do not exist, the defaults (if specified) are dumped to the specifiedWritableObject
dumpFile
.
WARNING: The specifiedPath
dir
has to be a directory!!!!!- Type Parameters:
T
- configuration type needed- Parameters:
dir
- the directory to load configurations fromconfigToResolveTo
- aSupplier
of the needed configuration objectsdumpFile
- the default dump file- Returns:
- a map of the loaded configurations, key being the file name. If the map is empty then AnnotationConfig couldn't find any configurations in the folder, and you should fall back to the defaults.
- Throws:
IllegalArgumentException
- if the specifieddir
is not a directory!
-
resolveMultiple
<T> Map<String,T> resolveMultiple(Path dir, Supplier<T> configToResolveTo, WritableObject dumpFile, Settings settings) Loads the configurations in thePath
dir
specified, and if any do not exist, the defaults (if specified) are dumped to the specifiedWritableObject
dumpFile
.
WARNING: The specifiedPath
dir
has to be a directory!!!!!- Type Parameters:
T
- configuration type needed- Parameters:
dir
- the directory to load configurations fromconfigToResolveTo
- aSupplier
of the needed configuration objectsdumpFile
- the default dump filesettings
- the load settings to use when loading the configurations- Returns:
- a map of the loaded configurations, key being the file name. If the map is empty then AnnotationConfig couldn't find any configurations in the folder, and you should fall back to the defaults.
- Throws:
IllegalArgumentException
- if the specifieddir
is not a directory!
-