Class ConfigurationParameters
- java.lang.Object
-
- org.apache.jackrabbit.oak.spi.security.ConfigurationParameters
-
- All Implemented Interfaces:
java.util.Map<java.lang.String,java.lang.Object>
public final class ConfigurationParameters extends java.lang.Object implements java.util.Map<java.lang.String,java.lang.Object>
ConfigurationParameters is a convenience class that allows typed access to configuration properties. It implements theMap
interface but is immutable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConfigurationParameters.Milliseconds
Helper class for configuration parameters that denote a "duration", such as a timeout or expiration time.
-
Field Summary
Fields Modifier and Type Field Description static ConfigurationParameters
EMPTY
An empty configuration parameters
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
contains(@NotNull java.lang.String key)
Returnstrue
if this instance contains a configuration entry with the specified key irrespective of the defined value;false
otherwise.boolean
containsKey(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
@NotNull java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>>
entrySet()
java.lang.Object
get(java.lang.Object key)
<T> T
getConfigValue(@NotNull java.lang.String key, T defaultValue)
Returns the value of the configuration entry with the givenkey
applying the following rules: If this instance doesn't contain a configuration entry with that key, or if the entry isnull
, the specifieddefaultValue
will be returned. If the configured value is notnull
an attempt is made to convert the configured value to match the type of the default value.<T> T
getConfigValue(@NotNull java.lang.String key, T defaultValue, @Nullable java.lang.Class<T> targetClass)
Returns the value of the configuration entry with the givenkey
applying the following rules: If this instance doesn't contain a configuration entry with that key the specifieddefaultValue
will be returned. IfdefaultValue
isnull
the original value will be returned. If the configured value isnull
this method will always returnnull
. If neitherdefaultValue
nor the configured value isnull
an attempt is made to convert the configured value to match the type of the default value.boolean
isEmpty()
@NotNull java.util.Set<java.lang.String>
keySet()
static @NotNull ConfigurationParameters
of(@NotNull java.lang.String key, @NotNull java.lang.Object value)
Creates new a single valued configuration parameters instance from the given key and value.static @NotNull ConfigurationParameters
of(@NotNull java.lang.String key1, @NotNull java.lang.Object value1, @NotNull java.lang.String key2, @NotNull java.lang.Object value2)
Creates new a configuration parameters instance from the given key and value pairs.static @NotNull ConfigurationParameters
of(@NotNull java.util.Dictionary<java.lang.String,java.lang.Object> properties)
Creates new a configuration parameters instance by copying the given properties.static @NotNull ConfigurationParameters
of(@NotNull java.util.Map<?,?> map)
Creates new a configuration parameters instance by copying the given map.static @NotNull ConfigurationParameters
of(@NotNull java.util.Properties properties)
Creates new a configuration parameters instance by copying the given properties.static @NotNull ConfigurationParameters
of(@NotNull ConfigurationParameters... params)
Creates a new configuration parameters instance by merging allparams
sequentially.java.lang.Object
put(java.lang.String key, java.lang.Object value)
void
putAll(@NotNull java.util.Map<? extends java.lang.String,?> m)
java.lang.Object
remove(java.lang.Object key)
int
size()
@NotNull java.util.Collection<java.lang.Object>
values()
-
-
-
Field Detail
-
EMPTY
public static final ConfigurationParameters EMPTY
An empty configuration parameters
-
-
Method Detail
-
of
@NotNull public static @NotNull ConfigurationParameters of(@NotNull @NotNull ConfigurationParameters... params)
Creates a new configuration parameters instance by merging allparams
sequentially. I.e. property define in subsequent arguments overwrite the ones before.- Parameters:
params
- source parameters to merge- Returns:
- merged configuration parameters or
EMPTY
if all source params were empty.
-
of
@NotNull public static @NotNull ConfigurationParameters of(@NotNull @NotNull java.util.Properties properties)
Creates new a configuration parameters instance by copying the given properties.- Parameters:
properties
- source properties- Returns:
- configuration parameters or
EMPTY
if the source properties were empty.
-
of
@NotNull public static @NotNull ConfigurationParameters of(@NotNull @NotNull java.util.Dictionary<java.lang.String,java.lang.Object> properties)
Creates new a configuration parameters instance by copying the given properties.- Parameters:
properties
- source properties- Returns:
- configuration parameters or
EMPTY
if the source properties were empty.
-
of
@NotNull public static @NotNull ConfigurationParameters of(@NotNull @NotNull java.util.Map<?,?> map)
Creates new a configuration parameters instance by copying the given map.- Parameters:
map
- source map- Returns:
- configuration parameters or
EMPTY
if the source map was empty.
-
of
@NotNull public static @NotNull ConfigurationParameters of(@NotNull @NotNull java.lang.String key, @NotNull @NotNull java.lang.Object value)
Creates new a single valued configuration parameters instance from the given key and value.- Parameters:
key
- The keyvalue
- The value- Returns:
- a new instance of configuration parameters.
-
of
@NotNull public static @NotNull ConfigurationParameters of(@NotNull @NotNull java.lang.String key1, @NotNull @NotNull java.lang.Object value1, @NotNull @NotNull java.lang.String key2, @NotNull @NotNull java.lang.Object value2)
Creates new a configuration parameters instance from the given key and value pairs.- Parameters:
key1
- The key of the first pair.value1
- The value of the first pairkey2
- The key of the second pair.value2
- The value of the second pair.- Returns:
- a new instance of configuration parameters.
-
contains
public boolean contains(@NotNull @NotNull java.lang.String key)
Returnstrue
if this instance contains a configuration entry with the specified key irrespective of the defined value;false
otherwise.- Parameters:
key
- The key to be tested.- Returns:
true
if this instance contains a configuration entry with the specified key irrespective of the defined value;false
otherwise.
-
getConfigValue
@Nullable public <T> T getConfigValue(@NotNull @NotNull java.lang.String key, @Nullable T defaultValue, @Nullable @Nullable java.lang.Class<T> targetClass)
Returns the value of the configuration entry with the givenkey
applying the following rules:- If this instance doesn't contain a configuration entry with that
key the specified
defaultValue
will be returned. - If
defaultValue
isnull
the original value will be returned. - If the configured value is
null
this method will always returnnull
. - If neither
defaultValue
nor the configured value isnull
an attempt is made to convert the configured value to match the type of the default value.
- Parameters:
key
- The name of the configuration option.defaultValue
- The default value to return if no such entry exists or to use for conversion.targetClass
- The target class- Returns:
- The original or converted configuration value or
null
.
- If this instance doesn't contain a configuration entry with that
key the specified
-
getConfigValue
@NotNull public <T> T getConfigValue(@NotNull @NotNull java.lang.String key, @NotNull T defaultValue)
Returns the value of the configuration entry with the givenkey
applying the following rules:- If this instance doesn't contain a configuration entry with that
key, or if the entry is
null
, the specifieddefaultValue
will be returned. - If the configured value is not
null
an attempt is made to convert the configured value to match the type of the default value.
- Parameters:
key
- The name of the configuration option.defaultValue
- The default value to return if no such entry exists or to use for conversion.- Returns:
- The original or converted configuration value or
defaultValue
if no entry for the given key exists.
- If this instance doesn't contain a configuration entry with that
key, or if the entry is
-
size
public int size()
- Specified by:
size
in interfacejava.util.Map<java.lang.String,java.lang.Object>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacejava.util.Map<java.lang.String,java.lang.Object>
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKey
in interfacejava.util.Map<java.lang.String,java.lang.Object>
-
containsValue
public boolean containsValue(java.lang.Object value)
- Specified by:
containsValue
in interfacejava.util.Map<java.lang.String,java.lang.Object>
-
get
public java.lang.Object get(java.lang.Object key)
- Specified by:
get
in interfacejava.util.Map<java.lang.String,java.lang.Object>
-
put
public java.lang.Object put(java.lang.String key, java.lang.Object value)
- Specified by:
put
in interfacejava.util.Map<java.lang.String,java.lang.Object>
-
remove
public java.lang.Object remove(java.lang.Object key)
- Specified by:
remove
in interfacejava.util.Map<java.lang.String,java.lang.Object>
-
putAll
public void putAll(@NotNull @NotNull java.util.Map<? extends java.lang.String,?> m)
- Specified by:
putAll
in interfacejava.util.Map<java.lang.String,java.lang.Object>
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Map<java.lang.String,java.lang.Object>
-
keySet
@NotNull public @NotNull java.util.Set<java.lang.String> keySet()
- Specified by:
keySet
in interfacejava.util.Map<java.lang.String,java.lang.Object>
-
values
@NotNull public @NotNull java.util.Collection<java.lang.Object> values()
- Specified by:
values
in interfacejava.util.Map<java.lang.String,java.lang.Object>
-
entrySet
@NotNull public @NotNull java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
- Specified by:
entrySet
in interfacejava.util.Map<java.lang.String,java.lang.Object>
-
-