@API(status=EXPERIMENTAL, since="1.3") public class PrefixedConfigurationParameters extends Object implements ConfigurationParameters
ConfigurationParameters
that applies a supplied prefix to all
queries.CONFIG_FILE_NAME
Constructor and Description |
---|
PrefixedConfigurationParameters(ConfigurationParameters delegate,
String prefix)
Create a new view of the supplied
ConfigurationParameters that
applies the supplied prefix to all queries. |
Modifier and Type | Method and Description |
---|---|
Optional<String> |
get(String key)
Get the configuration parameter stored under the specified
key . |
<T> Optional<T> |
get(String key,
Function<String,T> transformer)
Get and transform the configuration parameter stored under the specified
key using the specified transformer . |
Optional<Boolean> |
getBoolean(String key)
Get the boolean configuration parameter stored under the specified
key . |
int |
size()
Get the number of configuration parameters stored directly in this
ConfigurationParameters . |
public PrefixedConfigurationParameters(ConfigurationParameters delegate, String prefix)
ConfigurationParameters
that
applies the supplied prefix to all queries.delegate
- the ConfigurationParameters
to delegate to; never
null
prefix
- the prefix to apply to all queries; never null
or
blankpublic Optional<String> get(String key)
ConfigurationParameters
key
.
If no such key is present in this ConfigurationParameters
,
an attempt will be made to look up the value as a JVM system property.
If no such system property exists, an attempt will be made to look up
the value in the JUnit Platform properties
file.
get
in interface ConfigurationParameters
key
- the key to look up; never null
or blankOptional
containing the value; never null
but potentially emptyConfigurationParameters.getBoolean(String)
,
System.getProperty(String)
,
ConfigurationParameters.CONFIG_FILE_NAME
public Optional<Boolean> getBoolean(String key)
ConfigurationParameters
key
.
If no such key is present in this ConfigurationParameters
,
an attempt will be made to look up the value as a JVM system property.
If no such system property exists, an attempt will be made to look up
the value in the JUnit Platform properties
file.
getBoolean
in interface ConfigurationParameters
key
- the key to look up; never null
or blankOptional
containing the value; never null
but potentially emptyConfigurationParameters.get(String)
,
Boolean.parseBoolean(String)
,
System.getProperty(String)
,
ConfigurationParameters.CONFIG_FILE_NAME
public <T> Optional<T> get(String key, Function<String,T> transformer)
ConfigurationParameters
key
using the specified transformer
.
If no such key is present in this ConfigurationParameters
,
an attempt will be made to look up the value as a JVM system property.
If no such system property exists, an attempt will be made to look up
the value in the JUnit Platform properties
file.
In case the transformer throws an exception, it will be wrapped in a
JUnitException
with a helpful message.
get
in interface ConfigurationParameters
key
- the key to look up; never null
or blanktransformer
- the transformer to apply in case a value is found;
never null
Optional
containing the value; never null
but potentially emptyConfigurationParameters.getBoolean(String)
,
System.getProperty(String)
,
ConfigurationParameters.CONFIG_FILE_NAME
public int size()
ConfigurationParameters
ConfigurationParameters
.size
in interface ConfigurationParameters
Copyright © 2019. All rights reserved.