Class JacksonConfig<T>
- Type Parameters:
T
- type of main configuration
- All Implemented Interfaces:
DebugDataProvider
Each file is associated with a ConfigKey
, which provides a name, path and a default value.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAllows to register additional modules to the mapper.configureDefault
(MapperBuilder<?, ?> builder) protected final <V> V
createAndLoad
(ConfigKey<V> key) Load a file defined in the configuration key.protected ObjectMapper
Create a general mapper for read and write.protected ObjectMapper
Create a mapper for reading files.protected ObjectMapper
Create a mapper for writing files.<V> boolean
Checks whether the config file was created alreadyprotected de.eldoria.jacksonbukkit.JacksonBukkit
Create the module used for spigot/bukkit server.Get debug information for the current object instance.protected de.eldoria.jacksonbukkit.JacksonPaper
Create the module used for paper server.final Module
Get the module for the current platform.protected final <V> V
Load a file defined in the configuration key.<V> boolean
Checks whether the config file was already loadedmain()
Get the primary configuration.Get the primary configuration wrapper.final ObjectMapper
mapper()
Get the object mapper used to read and write objectsplugin()
Plugin associated with this configurationfinal ObjectMapper
reader()
Get the object mapper used to read filesvoid
reload()
Relaods all files loaded via this instance including the main configuration.void
Reloads a single file associated with the config key<V> void
Replace the configuration currently associated with this key with a new configuration.void
save()
Saves all files loaded via this instance.void
Saves the file associated with the config key<V> V
Get a configuration file.<V> Wrapper<V>
secondaryWrapped
(ConfigKey<V> key) Get a configuration file.final ObjectMapper
writer()
Get the mapper used to write objectsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface de.eldoria.eldoutilities.debug.DebugDataProvider
getDebugProviders
-
Constructor Details
-
JacksonConfig
Creates a new Jackson Configuration- Parameters:
plugin
- plugin owning the configurationmainKey
- key for the main configuration file former config.yml
-
-
Method Details
-
plugin
Plugin associated with this configuration- Returns:
- plugin instance
-
main
Get the primary configuration.This will be the config.yml in most cases.
If the config was not yet created, it will be created.
- Returns:
- configuration
-
secondary
Get a configuration file.If this file was not yet created, it will be created.
- Type Parameters:
V
- type of configuration- Parameters:
key
- configuration key- Returns:
- configuration file
-
mainWrapped
Get the primary configuration wrapper.This wrapper can be used to save the config using the closable. It is also safe to be stored since it does not store the file itself.
This will be the config.yml in most cases.
If the config was not yet created, it will be created.
- Returns:
- configuration
-
secondaryWrapped
Get a configuration file.This wrapper can be used to save the config using the closable. It is also safe to be stored since it does not store the file itself.
If this file was not yet created, it will be created.
- Type Parameters:
V
- type of configuration- Parameters:
key
- configuration key- Returns:
- configuration file
-
exists
Checks whether the config file was created already- Type Parameters:
V
- type- Parameters:
key
- key- Returns:
- true when exists
-
loaded
Checks whether the config file was already loaded- Type Parameters:
V
- type- Parameters:
key
- key- Returns:
- true when loaded
-
replace
Replace the configuration currently associated with this key with a new configuration.- Type Parameters:
V
- type of key- Parameters:
key
- configuration keynewValue
- new value of key
-
save
public void save()Saves all files loaded via this instance. -
save
Saves the file associated with the config key- Parameters:
key
- configuration key
-
reload
public void reload()Relaods all files loaded via this instance including the main configuration. -
reload
Reloads a single file associated with the config key- Parameters:
key
- configuration key
-
reader
Get the object mapper used to read files- Returns:
- object mapper instance
-
writer
Get the mapper used to write objects- Returns:
- object mapper instance
-
mapper
Get the object mapper used to read and write objects- Returns:
- object mapper instance
-
createReadMapper
Create a mapper for reading files.- Returns:
- mapper instance
-
createWriteMapper
Create a mapper for writing files.- Returns:
- mapper instance
-
load
Load a file defined in the configuration key.Will fail if the file is not present.
Use
createAndLoad(ConfigKey)
if you want the file to be created.- Type Parameters:
V
- type of file- Parameters:
key
- configuration key- Returns:
- instance of file
-
createAndLoad
Load a file defined in the configuration key.If this file was not yet created, it will be created.
- Type Parameters:
V
- type of file- Parameters:
key
- configuration key- Returns:
- instance of file
-
createMapper
Create a general mapper for read and write.You can define different wrapper for read and write operations by overwriting
createReadMapper()
andcreateWriteMapper()
- Returns:
- mapper instance
-
configureDefault
-
getPlatformModule
Get the module for the current platform.- Returns:
- module
-
additionalModules
Allows to register additional modules to the mapper.- Returns:
- list of modules.
-
getPaperModule
protected de.eldoria.jacksonbukkit.JacksonPaper getPaperModule()Create the module used for paper server.This should be a
JacksonPaper
module.- Returns:
- paper module
-
getBukkitModule
protected de.eldoria.jacksonbukkit.JacksonBukkit getBukkitModule()Create the module used for spigot/bukkit server.This should be a
JacksonBukkit
module.- Returns:
- spigot/bukkit module
-
getDebugInformations
Description copied from interface:DebugDataProvider
Get debug information for the current object instance.- Specified by:
getDebugInformations
in interfaceDebugDataProvider
- Returns:
- array of entry data.
-