Package com.hazelcast.spi.properties
Class HazelcastProperties
java.lang.Object
com.hazelcast.spi.properties.HazelcastProperties
Container for configured Hazelcast properties (see
HazelcastProperty
).
A HazelcastProperty
can be set as:
- a system property using
System.setProperty(String, String)
- the programmatic configuration using
Config.setProperty(String, String)
- the XML configuration
- See Also:
-
Constructor Summary
ConstructorDescriptionHazelcastProperties
(Config config) Creates a container with configured Hazelcast properties.HazelcastProperties
(Properties nullableProperties) Creates a container with configured Hazelcast properties. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(HazelcastProperty property) Returns true if value for given key is provided (either as a HazelcastProperty or a System property).Returns the value for the given key.boolean
getBoolean
(HazelcastProperty property) Returns the configured boolean value of aHazelcastProperty
.protected Config
double
getDouble
(HazelcastProperty property) Returns the configured double value of aHazelcastProperty
.<E extends Enum>
EgetEnum
(HazelcastProperty property, Class<E> enumClazz) Returns the configured enum value of aClusterProperty
.float
getFloat
(HazelcastProperty property) Returns the configured float value of aHazelcastProperty
.int
getInteger
(HazelcastProperty property) Returns the configured int value of aHazelcastProperty
.long
getLong
(HazelcastProperty property) Returns the configured long value of aHazelcastProperty
.long
getMillis
(HazelcastProperty property) Returns the configured value of aHazelcastProperty
converted to milliseconds.long
getNanos
(HazelcastProperty property) Returns the configured value of aHazelcastProperty
converted to nanoseconds.long
getPositiveMillisOrDefault
(HazelcastProperty property) Returns the configured value of aHazelcastProperty
converted to milliseconds if it is positive, otherwise returns its default value.long
getPositiveMillisOrDefault
(HazelcastProperty property, long defaultValue) Returns the configured value of aHazelcastProperty
converted to milliseconds if it is positive, otherwise returns the passed default value.int
getSeconds
(HazelcastProperty property) Returns the configured value of aHazelcastProperty
converted to seconds.getString
(HazelcastProperty property) Returns the configured value of aHazelcastProperty
as String.keySet()
Returns an immutable set of all keys in this HazelcastProperties.
-
Constructor Details
-
HazelcastProperties
Creates a container with configured Hazelcast properties.Uses the system property value if no value is defined in the configuration. Uses the default value if no system property value is defined.
- Parameters:
config
-Config
used to configure theHazelcastProperty
values; properties in config are allowed to benull
-
HazelcastProperties
Creates a container with configured Hazelcast properties.Uses the system property value if no value is defined in the configuration. Uses the default value if no system property value is defined.
- Parameters:
nullableProperties
-Properties
used to configure theHazelcastProperty
values; properties are allowed to benull
-
-
Method Details
-
getConfig
-
keySet
Returns an immutable set of all keys in this HazelcastProperties.- Returns:
- set of keys
-
get
Returns the value for the given key. If thisHazelcastProperties
object is initialized with a "compromised"Properties
object (ie one where keys/values of types other thanString
have been inserted), thenget
onString
keys mapped to non-String
values will returnnull
, similarly toProperties.getProperty(String)
.- Parameters:
key
- the key- Returns:
- the value for the given key, or
null
if no value is found - Throws:
NullPointerException
- if key isnull
-
getString
Returns the configured value of aHazelcastProperty
as String.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value or
null
if nothing has been configured
-
containsKey
Returns true if value for given key is provided (either as a HazelcastProperty or a System property). Default values are not taken into account.- Parameters:
property
- theHazelcastProperty
to check- Returns:
true
if the value was explicitly provided
-
getBoolean
Returns the configured boolean value of aHazelcastProperty
.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value as boolean
-
getInteger
Returns the configured int value of aHazelcastProperty
.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value as int
- Throws:
NumberFormatException
- if the value cannot be parsed
-
getLong
Returns the configured long value of aHazelcastProperty
.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value as long
- Throws:
NumberFormatException
- if the value cannot be parsed
-
getFloat
Returns the configured float value of aHazelcastProperty
.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value as float
- Throws:
NumberFormatException
- if the value cannot be parsed
-
getDouble
Returns the configured double value of aHazelcastProperty
.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value as double
- Throws:
NumberFormatException
- if the value cannot be parsed
-
getNanos
Returns the configured value of aHazelcastProperty
converted to nanoseconds.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value in nanoseconds
- Throws:
IllegalArgumentException
- if theHazelcastProperty
has noTimeUnit
-
getMillis
Returns the configured value of aHazelcastProperty
converted to milliseconds.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value in milliseconds
- Throws:
IllegalArgumentException
- if theHazelcastProperty
has noTimeUnit
-
getPositiveMillisOrDefault
Returns the configured value of aHazelcastProperty
converted to milliseconds if it is positive, otherwise returns its default value.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value in milliseconds if it is positive, otherwise its default value.
- Throws:
IllegalArgumentException
- if theHazelcastProperty
has noTimeUnit
-
getPositiveMillisOrDefault
Returns the configured value of aHazelcastProperty
converted to milliseconds if it is positive, otherwise returns the passed default value.- Parameters:
property
- theHazelcastProperty
to get the value fromdefaultValue
- the default value to return if property has non positive value.- Returns:
- the value in milliseconds if it is positive, otherwise the passed default value.
- Throws:
IllegalArgumentException
- if theHazelcastProperty
has noTimeUnit
-
getSeconds
Returns the configured value of aHazelcastProperty
converted to seconds.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value in seconds
- Throws:
IllegalArgumentException
- if theHazelcastProperty
has noTimeUnit
-
getEnum
Returns the configured enum value of aClusterProperty
.The case of the enum is ignored.
- Type Parameters:
E
- the enum type- Parameters:
property
- theClusterProperty
to get the value from- Returns:
- the enum
- Throws:
IllegalArgumentException
- if the enum value can't be found
-