public.javadoc.org.spincast.plugins.config.ConfigFinder.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-website Show documentation
Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
ConfigFinder (org.spincast:spincast-framework 1.14.0 API)
org.spincast.plugins.config
Class ConfigFinder
- java.lang.Object
-
- org.spincast.plugins.config.ConfigFinder
-
- Direct Known Subclasses:
- SpincastConfigDefault
public class ConfigFinder
extends Object
-
-
Nested Class Summary
Nested Classes
Modifier and Type
Class and Description
static class
ConfigFinder.ConfigFinderBuilder
-
Field Summary
Fields
Modifier and Type
Field and Description
protected Map<String,Object>
configs
protected static org.slf4j.Logger
logger
protected Map<String,Object>
rawConfigs
-
Constructor Summary
Constructors
Modifier
Constructor and Description
protected
ConfigFinder(String classpathFilePath,
String externalFilePath,
List<String> environmentVariablesPrefixes,
boolean environmentVariablesStripPrefix,
List<String> systemPropertiesPrefixes,
boolean systemPropertiesStripPrefix,
boolean externalFileConfigsOverrideEnvironmentVariables,
boolean throwExceptionIfSpecifiedClasspathConfigFileIsNotFound,
boolean throwExceptionIfSpecifiedExternalConfigFileIsNotFound)
This component is not part of the Guice context because
you can very easily created circular dependencies with
configurations since they are used everywhere.
-
Method Summary
-
-
Constructor Detail
-
ConfigFinder
protected ConfigFinder(String classpathFilePath,
String externalFilePath,
List<String> environmentVariablesPrefixes,
boolean environmentVariablesStripPrefix,
List<String> systemPropertiesPrefixes,
boolean systemPropertiesStripPrefix,
boolean externalFileConfigsOverrideEnvironmentVariables,
boolean throwExceptionIfSpecifiedClasspathConfigFileIsNotFound,
boolean throwExceptionIfSpecifiedExternalConfigFileIsNotFound)
This component is not part of the Guice context because
you can very easily created circular dependencies with
configurations since they are used everywhere.
-
Method Detail
-
configure
public static ConfigFinder.ConfigFinderBuilder configure()
-
getClasspathFilePath
protected String getClasspathFilePath()
-
getExternalFilePath
protected String getExternalFilePath()
-
isEnvironmentVariablesStripPrefix
protected boolean isEnvironmentVariablesStripPrefix()
-
isSystemPropertiesStripPrefix
protected boolean isSystemPropertiesStripPrefix()
-
isExternalFileConfigsOverrideEnvironmentVariables
protected boolean isExternalFileConfigsOverrideEnvironmentVariables()
-
isThrowExceptionIfSpecifiedClasspathConfigFileIsNotFound
protected boolean isThrowExceptionIfSpecifiedClasspathConfigFileIsNotFound()
-
isThrowExceptionIfSpecifiedExternalConfigFileIsNotFound
protected boolean isThrowExceptionIfSpecifiedExternalConfigFileIsNotFound()
-
loadYamlFileConfigs
protected void loadYamlFileConfigs(File configFile,
org.yaml.snakeyaml.Yaml yaml)
-
expandMap
protected Map<String,Object> expandMap(Map<String,Object> sourceMap)
Parses the keys of the map as "dotted paths" and created
an expanded Map from them.
-
mergeMaps
protected Map<String,Object> mergeMaps(Map<String,Object> map1,
Map<String,Object> map2)
Merges two maps :
The elements from the second map override the elements of
the first map of the same path, except for Map elements which
are merged.
-
getRawConfig
public Object getRawConfig(String dottedKey)
Gets a config from the raw Map. The dotted key
will be parsed as the path to use.
-
getConfigFromMap
public Object getConfigFromMap(Map<String,Object> map,
String dottedKey)
Gets a config from the given Map. The dotted key
will be parsed as the path to use.
- Returns:
- the config value or
null
if not found.
-
getConfigFromMap
public Object getConfigFromMap(Map<String,Object> map,
String dottedKey,
Object defaultValue)
Gets a config from the given Map. The dotted key
will be parsed as the path to use.
- Returns:
- the config value or the default value if not found.
-
getConfig
public Object getConfig(String key,
Object defaultValue)
Gets an untype config from the config map. If the
config isn't there, we'll try to get it from
the raw configs map.
If the resulting config is null
, the
default value will be returned.
-
getMapList
public List<Map<String,Object>> getMapList(String key,
List<Map<String,Object>> defaultValue)
-
getBigDecimalFromElement
protected BigDecimal getBigDecimalFromElement(Object val)
-
getBigDecimal
public BigDecimal getBigDecimal(String key)
-
getBigDecimal
public BigDecimal getBigDecimal(String key,
BigDecimal defaultValue)
-
getBigDecimalList
public List<BigDecimal> getBigDecimalList(String key)
-
getBigDecimalList
public List<BigDecimal> getBigDecimalList(String key,
List<BigDecimal> defaultValue)
-
getAppJarDirectory
protected File getAppJarDirectory()
If the project is running from an executable
.jar file, this will return the directory containing
this .jar file.
- Returns:
- the directory path or
null
if the
application is not running from an executable .jar
file.
-
getAppRootDirectoryNoJar
protected File getAppRootDirectoryNoJar()
If the project is not running from an executable
.jar file, this will return the root directory of the
project on the file system.
- Returns:
- the directory path or
null
if the
application is running from an executable .jar
file.
Copyright © 2019. All rights reserved.