Class Config
java.lang.Object
com.erudika.para.core.utils.Config
- Direct Known Subclasses:
ParaConfig
This class loads configuration settings from a file and sets defaults.
- Author:
- Alex Bogdanovski [[email protected]]
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String"appid".static final String"creatorid".static final String"email".static final String"etoken".static final String"groups".static final String"id".static final String"identifier".static final String"key".static final String"name".static final String"parentid".static final String"password".static final String"properties".static final String"token".static final String"tags".static final String"timestamp".static final String"type".static final String"updated".static final String"version".static final StringAmazon prefix - defaults to 'az:'.static final int10000.static final StringFacebook prefix - defaults to 'fb:'.static final StringGitHub prefix - defaults to 'gh:'.static final StringGoogle prefix - defaults to 'gp:'.static final StringLDAP prefix - defaults to 'ldap:'.static final StringLinkedIn prefix - defaults to 'in:'.static final StringMattermost prefix - defaults to 'mm:'.static final StringMicrosoft prefix - defaults to 'ms:'.static final StringOAuth2 generic prefix - defaults to 'oa2:'.static final StringOAuth2 second generic prefix - defaults to 'oa2second:'.static final StringOAuth2 third generic prefix - defaults to 'oa2third:'.static final String"para".static final StringPasswordless auth prefix - defaults to 'custom:'.static final StringSAML prefix - defaults to 'saml:'.static final StringSlack prefix - defaults to 'sl:'.static final StringTwitter prefix - defaults to 'tw:'. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.typesafe.config.ConfigReturns the Config object.The name of the configuration file, usually 'app-application.conf'.abstract StringThe root prefix of the configuration property names, e.g.getConfigValue(String key, String defaultValue) Returns the unwrapped value of a configuration parameter or its default value.Constructs a sorted set of configuration keys.overwriteConfig(com.typesafe.config.Config newConfig) Overwrites the internal config object with a new one.static com.typesafe.config.ConfigparseFileWithoutIncludes(File file) Parses a HOCON file with includes disabled.static com.typesafe.config.ConfigparseStringWithoutIncludes(String config) Parses a HOCON string with includes disabled.render(boolean asJson) Renders the current configuration as a String, taking into account system properties and ENV precedence ordering.renderConfigDocumentation(String format, boolean groupByCategory) Renders all configuration options along with their documentation and default values.voidstore()Stores all available configuration to a file, overwriting the existing one.
-
Field Details
-
PARA
-
_TYPE
-
_APPID
-
_CREATORID
-
_ID
-
_IDENTIFIER
-
_KEY
-
_NAME
-
_PARENTID
-
_PASSWORD
-
_RESET_TOKEN
-
_EMAIL_TOKEN
-
_TIMESTAMP
-
_UPDATED
-
_TAGS
-
_EMAIL
-
_GROUPS
-
_VERSION
-
_PROPERTIES
-
DEFAULT_LIMIT
public static final int DEFAULT_LIMIT10000.- See Also:
-
FB_PREFIX
-
GPLUS_PREFIX
-
LINKEDIN_PREFIX
-
TWITTER_PREFIX
-
GITHUB_PREFIX
-
MICROSOFT_PREFIX
-
SLACK_PREFIX
-
MATTERMOST_PREFIX
-
AMAZON_PREFIX
-
OAUTH2_PREFIX
-
OAUTH2_SECOND_PREFIX
OAuth2 second generic prefix - defaults to 'oa2second:'.- See Also:
-
OAUTH2_THIRD_PREFIX
OAuth2 third generic prefix - defaults to 'oa2third:'.- See Also:
-
LDAP_PREFIX
-
SAML_PREFIX
-
PASSWORDLESS_PREFIX
Passwordless auth prefix - defaults to 'custom:'.- See Also:
-
-
Constructor Details
-
Config
public Config()
-
-
Method Details
-
getConfigFilePath
The name of the configuration file, usually 'app-application.conf'.- Returns:
- prefix-application.conf or the value of @{code config.file} system property.
-
getConfigRootPrefix
The root prefix of the configuration property names, e.g. "para".- Returns:
- the root prefix for all config property keys.
-
getConfigValue
-
getConfig
public com.typesafe.config.Config getConfig()Returns the Config object.- Returns:
- the config object
-
overwriteConfig
Overwrites the internal config object with a new one.- Parameters:
newConfig- a new Config object- Returns:
- returns this instance for chaining
-
getSortedConfigKeys
Constructs a sorted set of configuration keys. Heavily relies on theDocumentedannotation for sort order.- Returns:
- a set of map of config keys, without the root prefix (path), to config categories.
-
store
public void store()Stores all available configuration to a file, overwriting the existing one. In case of HOCON, the commented lines are collected from existing file and appended at the end. -
render
- Parameters:
asJson- if true, a JSON object will be rendered, otherwise the HOCON format is used- Returns:
- config as string
- See Also:
-
render
Renders the current configuration as a String, taking into account system properties and ENV precedence ordering.- Parameters:
asJson- if true, a JSON object will be rendered, otherwise the HOCON format is usedhoconHeader- file headerhoconFooter- file footer- Returns:
- config as string
-
renderConfigDocumentation
Renders all configuration options along with their documentation and default values.- Parameters:
format- one of "hocon", "json" or "markdown"groupByCategory- if true, will group properties by category- Returns:
- a HOCON, JSON or MD string
-
getConfigMap
-
parseFileWithoutIncludes
Parses a HOCON file with includes disabled.- Parameters:
file- a file- Returns:
- a Config object
-
parseStringWithoutIncludes
Parses a HOCON string with includes disabled.- Parameters:
config- HOCON confing string- Returns:
- a Config object
-