public class JsonProperties extends Properties
java.util.Properties implementation, that is able to parse a properties file in json format.
Restrictions: supported types: String and (nested) Object ; other types in json file are ignored.
Nested objects key names are separated by '.'
Example:
{ "name": {"firstName": "Bart", "lastName": "Simpson"}}
produces the properties:
name.firstName = "Bart"
name.lastName = "Simpson"
Additional features:
- an additional 'defaults' properties list, my by provided in the constructors.
- defaults for the manadatory properties required by the RestClient may also be set by named setters (e.g. setUserName())
- a validate method checks if all required properties for RestClient are available| Modifier and Type | Field and Description |
|---|---|
static String |
API_KEY |
static String |
API_PATH |
static String |
BASE_URL |
static String |
PROXY_PASS |
static String |
PROXY_PORT |
static String |
PROXY_URL |
static String |
PROXY_USER |
static String |
USER_NAME |
defaults| Constructor and Description |
|---|
JsonProperties(InputStream is) |
JsonProperties(InputStream is,
Properties defaults) |
JsonProperties(String filename) |
JsonProperties(String filename,
Properties defaults) |
| Modifier and Type | Method and Description |
|---|---|
void |
setApiKey(String apiKey) |
void |
setApiPath(String apiPath) |
void |
setBaseUrl(String baseUrl) |
void |
setProxyPass(String proxyPass) |
void |
setProxyPort(String proxyPort) |
void |
setProxyUrl(String proxyUrl) |
void |
setProxyUser(String proxyUser) |
void |
setUserName(String userName) |
List<String> |
validate(String... keys)
check if minimum required parameters are set:
"userName", "apiKey", "baseUrl", "apiPath"
|
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNamesclear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, merge, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, size, toString, valuespublic static final String USER_NAME
public static final String API_KEY
public static final String BASE_URL
public static final String API_PATH
public static final String PROXY_URL
public static final String PROXY_PORT
public static final String PROXY_USER
public static final String PROXY_PASS
public JsonProperties(String filename) throws IOException
IOExceptionpublic JsonProperties(String filename, Properties defaults) throws IOException
IOExceptionpublic JsonProperties(InputStream is) throws IOException
IOExceptionpublic JsonProperties(InputStream is, Properties defaults) throws IOException
IOExceptionpublic void setUserName(String userName)
public void setApiKey(String apiKey)
public void setBaseUrl(String baseUrl)
public void setApiPath(String apiPath)
public void setProxyUrl(String proxyUrl)
public void setProxyPort(String proxyPort)
public void setProxyUser(String proxyUser)
public void setProxyPass(String proxyPass)
Copyright © 2018 EACG, Enterprise Architecture Consulting Group GmbH. All rights reserved.