public class Config extends Object
Modifier and Type | Field and Description |
---|---|
static String |
OAUTH_CLIENT_ID |
static String |
OAUTH_CLIENT_SECRET |
static String |
OAUTH_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM |
static String |
OAUTH_SSL_SECURE_RANDOM_IMPLEMENTATION |
static String |
OAUTH_SSL_TRUSTSTORE_LOCATION |
static String |
OAUTH_SSL_TRUSTSTORE_PASSWORD |
static String |
OAUTH_SSL_TRUSTSTORE_TYPE |
static String |
OAUTH_USERNAME_CLAIM |
Constructor and Description |
---|
Config()
Use this construtor if you only want to lookup configuration in system properties and env
without any default configuration.
|
Config(Properties p)
Use this constructor to provide default values in case some configuration is not set through system properties or ENV.
|
Modifier and Type | Method and Description |
---|---|
String |
getValue(String key)
Get value for property key or null if not found
|
String |
getValue(String key,
String fallback)
Get value for property key, returning fallback value if configuration for key is not found.
|
boolean |
getValueAsBoolean(String key,
boolean fallback)
Get value for property key as boolean or fallback value if not found
Valid values are: "true", "false", "yes", "no", "y", "n", "1", "0"
|
int |
getValueAsInt(String key,
int fallback)
Get value for property key as int or fallback value if not found
|
static String |
toEnvName(String key)
Convert property key to env key.
|
void |
validate()
Validate configuration by checking for unknown or missing properties.
|
public static final String OAUTH_CLIENT_ID
public static final String OAUTH_CLIENT_SECRET
public static final String OAUTH_USERNAME_CLAIM
public static final String OAUTH_SSL_TRUSTSTORE_LOCATION
public static final String OAUTH_SSL_TRUSTSTORE_PASSWORD
public static final String OAUTH_SSL_TRUSTSTORE_TYPE
public static final String OAUTH_SSL_SECURE_RANDOM_IMPLEMENTATION
public static final String OAUTH_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM
public Config()
public Config(Properties p)
p
- Default property valuespublic void validate()
RuntimeException
- if validation failspublic String getValue(String key, String fallback)
key
- Config keyfallback
- Fallback valuepublic String getValue(String key)
key
- Config keypublic int getValueAsInt(String key, int fallback)
key
- Config keyfallback
- Fallback valuepublic boolean getValueAsBoolean(String key, boolean fallback)
key
- Config keyfallback
- Fallback valuepublic static String toEnvName(String key)
key
- A key of a property which should be converted to environment variable nameCopyright © 2019. All rights reserved.