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
-
Constructor Summary
ConstructorDescriptionCreates a container with configured Hazelcast properties.HazelcastProperties
(ClientConfig clientConfig) 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 a { HazelcastProperty}.double
getDouble
(HazelcastProperty property) Returns the configured double value of a { HazelcastProperty}.<E extends Enum>
EgetEnum
(HazelcastProperty property, Class<E> enumClazz) Returns the configured enum value of a { ClusterProperty}.float
getFloat
(HazelcastProperty property) Returns the configured float value of a { HazelcastProperty}.int
getInteger
(HazelcastProperty property) Returns the configured int value of a { HazelcastProperty}.long
getLong
(HazelcastProperty property) Returns the configured long value of a { HazelcastProperty}.long
getMillis
(HazelcastProperty property) Returns the configured value of a { HazelcastProperty} converted to milliseconds.long
getNanos
(HazelcastProperty property) Returns the configured value of a { HazelcastProperty} converted to nanoseconds.long
getPositiveMillisOrDefault
(HazelcastProperty property) Returns the configured value of a { HazelcastProperty} converted to milliseconds if it is positive, otherwise returns its default value.long
getPositiveMillisOrDefault
(HazelcastProperty property, long defaultValue) Returns the configured value of a { HazelcastProperty} converted to milliseconds if it is positive, otherwise returns the passed default value.int
getSeconds
(HazelcastProperty property) Returns the configured value of a { HazelcastProperty} converted to seconds.getString
(HazelcastProperty property) Returns the configured value of a { HazelcastProperty} as String.keySet()
Returns an immutable set of all keys in this HazelcastProperties.
-
Constructor Details
-
HazelcastProperties
public 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.
-
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.
-
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 the { HazelcastProperty} values; properties are allowed to benull
-
-
Method Details
-
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 to { Properties#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 a { HazelcastProperty} as String.- Parameters:
property
- the { HazelcastProperty} 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
- the { HazelcastProperty} to check- Returns:
true
if the value was explicitly provided
-
getBoolean
Returns the configured boolean value of a { HazelcastProperty}.- Parameters:
property
- the { HazelcastProperty} to get the value from- Returns:
- the value as boolean
-
getInteger
Returns the configured int value of a { HazelcastProperty}.- Parameters:
property
- the { HazelcastProperty} 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 a { HazelcastProperty}.- Parameters:
property
- the { HazelcastProperty} 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 a { HazelcastProperty}.- Parameters:
property
- the { HazelcastProperty} 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 a { HazelcastProperty}.- Parameters:
property
- the { HazelcastProperty} to get the value from- Returns:
- the value as double
- Throws:
NumberFormatException
- if the value cannot be parsed
-
getNanos
Returns the configured value of a { HazelcastProperty} converted to nanoseconds.- Parameters:
property
- the { HazelcastProperty} to get the value from- Returns:
- the value in nanoseconds
- Throws:
IllegalArgumentException
- if the { HazelcastProperty} has no { TimeUnit}
-
getMillis
Returns the configured value of a { HazelcastProperty} converted to milliseconds.- Parameters:
property
- the { HazelcastProperty} to get the value from- Returns:
- the value in milliseconds
- Throws:
IllegalArgumentException
- if the { HazelcastProperty} has no { TimeUnit}
-
getPositiveMillisOrDefault
Returns the configured value of a { HazelcastProperty} converted to milliseconds if it is positive, otherwise returns its default value.- Parameters:
property
- the { HazelcastProperty} to get the value from- Returns:
- the value in milliseconds if it is positive, otherwise its default value.
- Throws:
IllegalArgumentException
- if the { HazelcastProperty} has no { TimeUnit}
-
getPositiveMillisOrDefault
Returns the configured value of a { HazelcastProperty} converted to milliseconds if it is positive, otherwise returns the passed default value.- Parameters:
property
- the { HazelcastProperty} 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 the { HazelcastProperty} has no { TimeUnit}
-
getSeconds
Returns the configured value of a { HazelcastProperty} converted to seconds.- Parameters:
property
- the { HazelcastProperty} to get the value from- Returns:
- the value in seconds
- Throws:
IllegalArgumentException
- if the { HazelcastProperty} has no { TimeUnit}
-
getEnum
Returns the configured enum value of a { ClusterProperty}.The case of the enum is ignored.
- Type Parameters:
E
- the enum type- Parameters:
property
- the { ClusterProperty} to get the value from- Returns:
- the enum
- Throws:
IllegalArgumentException
- if the enum value can't be found
-