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
ConstructorsConstructorDescriptionHazelcastProperties(Config config) Creates a container with configured Hazelcast properties.HazelcastProperties(Properties nullableProperties) Creates a container with configured Hazelcast properties. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(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.booleangetBoolean(HazelcastProperty property) Returns the configured boolean value of aHazelcastProperty.protected ConfigdoublegetDouble(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.floatgetFloat(HazelcastProperty property) Returns the configured float value of aHazelcastProperty.intgetInteger(HazelcastProperty property) Returns the configured int value of aHazelcastProperty.longgetLong(HazelcastProperty property) Returns the configured long value of aHazelcastProperty.longgetMillis(HazelcastProperty property) Returns the configured value of aHazelcastPropertyconverted to milliseconds.longgetNanos(HazelcastProperty property) Returns the configured value of aHazelcastPropertyconverted to nanoseconds.longgetPositiveMillisOrDefault(HazelcastProperty property) Returns the configured value of aHazelcastPropertyconverted to milliseconds if it is positive, otherwise returns its default value.longgetPositiveMillisOrDefault(HazelcastProperty property, long defaultValue) Returns the configured value of aHazelcastPropertyconverted to milliseconds if it is positive, otherwise returns the passed default value.intgetSeconds(HazelcastProperty property) Returns the configured value of aHazelcastPropertyconverted to seconds.getString(HazelcastProperty property) Returns the configured value of aHazelcastPropertyas 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-Configused to configure theHazelcastPropertyvalues; 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-Propertiesused to configure theHazelcastPropertyvalues; 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 thisHazelcastPropertiesobject is initialized with a "compromised"Propertiesobject (ie one where keys/values of types other thanStringhave been inserted), thengetonStringkeys mapped to non-Stringvalues will returnnull, similarly toProperties.getProperty(String).- Parameters:
key- the key- Returns:
- the value for the given key, or
nullif no value is found - Throws:
NullPointerException- if key isnull
-
getString
Returns the configured value of aHazelcastPropertyas String.- Parameters:
property- theHazelcastPropertyto get the value from- Returns:
- the value or
nullif 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- theHazelcastPropertyto check- Returns:
trueif the value was explicitly provided
-
getBoolean
Returns the configured boolean value of aHazelcastProperty.- Parameters:
property- theHazelcastPropertyto get the value from- Returns:
- the value as boolean
-
getInteger
Returns the configured int value of aHazelcastProperty.- Parameters:
property- theHazelcastPropertyto 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- theHazelcastPropertyto 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- theHazelcastPropertyto 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- theHazelcastPropertyto get the value from- Returns:
- the value as double
- Throws:
NumberFormatException- if the value cannot be parsed
-
getNanos
Returns the configured value of aHazelcastPropertyconverted to nanoseconds.- Parameters:
property- theHazelcastPropertyto get the value from- Returns:
- the value in nanoseconds
- Throws:
IllegalArgumentException- if theHazelcastPropertyhas noTimeUnit
-
getMillis
Returns the configured value of aHazelcastPropertyconverted to milliseconds.- Parameters:
property- theHazelcastPropertyto get the value from- Returns:
- the value in milliseconds
- Throws:
IllegalArgumentException- if theHazelcastPropertyhas noTimeUnit
-
getPositiveMillisOrDefault
Returns the configured value of aHazelcastPropertyconverted to milliseconds if it is positive, otherwise returns its default value.- Parameters:
property- theHazelcastPropertyto get the value from- Returns:
- the value in milliseconds if it is positive, otherwise its default value.
- Throws:
IllegalArgumentException- if theHazelcastPropertyhas noTimeUnit
-
getPositiveMillisOrDefault
Returns the configured value of aHazelcastPropertyconverted to milliseconds if it is positive, otherwise returns the passed default value.- Parameters:
property- theHazelcastPropertyto 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 theHazelcastPropertyhas noTimeUnit
-
getSeconds
Returns the configured value of aHazelcastPropertyconverted to seconds.- Parameters:
property- theHazelcastPropertyto get the value from- Returns:
- the value in seconds
- Throws:
IllegalArgumentException- if theHazelcastPropertyhas noTimeUnit
-
getEnum
Returns the configured enum value of aClusterProperty.The case of the enum is ignored.
- Type Parameters:
E- the enum type- Parameters:
property- theClusterPropertyto get the value from- Returns:
- the enum
- Throws:
IllegalArgumentException- if the enum value can't be found
-