public final class ConfigFactory
extends java.lang.Object
org.aeonbits.owner
.
This class wraps functionality in the org.aeonbits.owner
configuration utilities to be a more GATK-specific
interface.
Created by jonn on 7/19/17.Modifier and Type | Method and Description |
---|---|
<T extends org.aeonbits.owner.Config> |
create(java.lang.Class<? extends T> clazz,
java.util.Map<?,?>... imports)
Wrapper around
ConfigFactory.create(Class, Map[]) which will ensure that
path variables specified in Config.Sources annotations are resolved prior
to creation. |
static <T extends org.aeonbits.owner.Config> |
dumpConfigSettings(T config,
java.nio.file.Path outFilePath)
Dump the configuration to a file that can be easily read into
Properties . |
<T extends org.aeonbits.owner.Config> |
get(java.lang.Object key)
Wrapper around
ConfigCache.get(Object) . |
static java.lang.String |
getConfigFilenameFromArgs(java.lang.String[] args,
java.lang.String configFileOption)
Get the configuration file name from the given arguments.
|
GATKConfig |
getGATKConfig()
Quick way to get the GATK configuration.
|
static ConfigFactory |
getInstance() |
<T extends org.aeonbits.owner.Config> |
getOrCreate(java.lang.Class<? extends T> clazz,
java.util.Map<?,?>... imports)
Wrapper around
ConfigCache.getOrCreate(Class, Map[]) which will ensure that
path variables specified in Config.Sources annotations are resolved prior
to creation. |
<T extends org.aeonbits.owner.Config> |
getOrCreate(org.aeonbits.owner.Factory factory,
java.lang.Class<? extends T> clazz,
java.util.Map<?,?>... imports)
Wrapper around
ConfigCache.getOrCreate(Factory, Class, Map[]) which will ensure that
path variables specified in Config.Sources annotations are resolved prior
to creation. |
<T extends org.aeonbits.owner.Config> |
getOrCreate(org.aeonbits.owner.Factory factory,
java.lang.Object key,
java.lang.Class<? extends T> clazz,
java.util.Map<?,?>... imports)
Wrapper around
ConfigCache.getOrCreate(Factory, Object, Class, Map[]) which will ensure that
path variables specified in Config.Sources annotations are resolved prior
to creation. |
<T extends org.aeonbits.owner.Config> |
getOrCreate(java.lang.Object key,
java.lang.Class<? extends T> clazz,
java.util.Map<?,?>... imports)
Wrapper around
ConfigCache.getOrCreate(Object, Class, Map[]) which will ensure that
path variables specified in Config.Sources annotations are resolved prior
to creation. |
void |
initializeConfigurationsFromCommandLineArgs(java.lang.String[] argList,
java.lang.String configFileOption)
Get the configuration filename from the command-line (if it exists) and create a configuration for it.
|
<T extends org.aeonbits.owner.Config> |
initializeConfigurationsFromCommandLineArgs(java.lang.String[] argList,
java.lang.String configFileOption,
java.lang.Class<? extends T> configClass)
Get the configuration from filename the command-line (if it exists) and create a configuration for it of the given type.
|
<T extends org.aeonbits.owner.Config> |
injectSystemPropertiesFromConfig(T config)
Injects system properties from the given configuration file.
|
static <T extends org.aeonbits.owner.Config> |
logConfigFields(T config)
Logs all the parameters in the given
Config object at Level.DEBUG |
static <T extends org.aeonbits.owner.Config> |
logConfigFields(T config,
htsjdk.samtools.util.Log.LogLevel logLevel)
Logs all the parameters in the given
Config object at the given Log.LogLevel |
public static ConfigFactory getInstance()
ConfigFactory
, which can be used to create a configuration.public GATKConfig getGATKConfig()
public static <T extends org.aeonbits.owner.Config> void dumpConfigSettings(T config, java.nio.file.Path outFilePath)
Properties
.T
- Some configuration class that extends Config
.config
- Configuration instance to dump.outFilePath
- Path
to output location.public <T extends org.aeonbits.owner.Config> T create(java.lang.Class<? extends T> clazz, java.util.Map<?,?>... imports)
ConfigFactory.create(Class, Map[])
which will ensure that
path variables specified in Config.Sources
annotations are resolved prior
to creation.
Creates a Config
instance from the specified interfaceT
- type of the interface.clazz
- the interface extending from Config
that you want to instantiate.imports
- additional variables to be used to resolve the properties.public <T extends org.aeonbits.owner.Config> T getOrCreate(java.lang.Class<? extends T> clazz, java.util.Map<?,?>... imports)
ConfigCache.getOrCreate(Class, Map[])
which will ensure that
path variables specified in Config.Sources
annotations are resolved prior
to creation.
Gets from the cache or create, an instance of the given class using the given imports.
The factory used to create new instances is the static ConfigFactory.INSTANCE
.T
- type of the interface.clazz
- the interface extending from Config
that you want to instantiate.imports
- additional variables to be used to resolve the properties.public <T extends org.aeonbits.owner.Config> T getOrCreate(org.aeonbits.owner.Factory factory, java.lang.Class<? extends T> clazz, java.util.Map<?,?>... imports)
ConfigCache.getOrCreate(Factory, Class, Map[])
which will ensure that
path variables specified in Config.Sources
annotations are resolved prior
to creation.
Gets from the cache or create, an instance of the given class using the given imports.T
- type of the interface.factory
- the factory to use to eventually create the instance.clazz
- the interface extending from Config
that you want to instantiate.imports
- additional variables to be used to resolve the properties.public <T extends org.aeonbits.owner.Config> T getOrCreate(java.lang.Object key, java.lang.Class<? extends T> clazz, java.util.Map<?,?>... imports)
ConfigCache.getOrCreate(Object, Class, Map[])
which will ensure that
path variables specified in Config.Sources
annotations are resolved prior
to creation.
Gets from the cache or create, an instance of the given class using the given imports.
The factory used to create new instances is the static ConfigFactory.INSTANCE
.T
- type of the interface.key
- the key object to be used to identify the instance in the cache.clazz
- the interface extending from Config
that you want to instantiate.imports
- additional variables to be used to resolve the properties.public <T extends org.aeonbits.owner.Config> T getOrCreate(org.aeonbits.owner.Factory factory, java.lang.Object key, java.lang.Class<? extends T> clazz, java.util.Map<?,?>... imports)
ConfigCache.getOrCreate(Factory, Object, Class, Map[])
which will ensure that
path variables specified in Config.Sources
annotations are resolved prior
to creation.T
- type of the interface.factory
- the factory to use to eventually create the instance.key
- the key object to be used to identify the instance in the cache.clazz
- the interface extending from Config
that you want to instantiate.imports
- additional variables to be used to resolve the properties.public <T extends org.aeonbits.owner.Config> T get(java.lang.Object key)
ConfigCache.get(Object)
.
This method is here to complete the interface for getting Config
objects.
Gets from the cache the Config
instance identified by the given key.T
- type of the interface.key
- the key object to be used to identify the instance in the cache.Config
object from the cache if exists, or null if it doesn't.public static java.lang.String getConfigFilenameFromArgs(java.lang.String[] args, java.lang.String configFileOption)
args
- Command-line arguments passed to this program.configFileOption
- The command-line option indicating that the config file is nextnull
.public void initializeConfigurationsFromCommandLineArgs(java.lang.String[] argList, java.lang.String configFileOption)
GATKConfig
Also sets system-level properties from the system config file.argList
- The list of arguments from which to read the config file.configFileOption
- The command-line option specifying the main configuration file.public <T extends org.aeonbits.owner.Config> void initializeConfigurationsFromCommandLineArgs(java.lang.String[] argList, java.lang.String configFileOption, java.lang.Class<? extends T> configClass)
argList
- The list of arguments from which to read the config file.configFileOption
- The command-line option specifying the main configuration file.configClass
- The class of the configuration file to instantiate.public <T extends org.aeonbits.owner.Config> void injectSystemPropertiesFromConfig(T config)
SystemProperty
annotation.
This will NOT override properties that already exist in the system.config
- The GATKConfig
object from which to inject system properties.public static <T extends org.aeonbits.owner.Config> void logConfigFields(T config)
Config
object at Level.DEBUG
T
- any Config
type to use to log all configuration information.config
- A Config
object from which to log all parameters and values.public static <T extends org.aeonbits.owner.Config> void logConfigFields(T config, htsjdk.samtools.util.Log.LogLevel logLevel)
Config
object at the given Log.LogLevel
T
- any Config
type to use to log all configuration information.config
- A Config
object from which to log all parameters and values.logLevel
- The log Log.LogLevel
at which to log the data in config