Package com.hazelcast.spi.properties
Class HazelcastProperties
- java.lang.Object
-
- com.hazelcast.spi.properties.HazelcastProperties
-
public class HazelcastProperties extends java.lang.Object
Container for configured Hazelcast properties (seeHazelcastProperty
).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:
- System properties documentaiton
- a system property using
-
-
Constructor Summary
Constructors Constructor Description HazelcastProperties(Config config)
Creates a container with configured Hazelcast properties.HazelcastProperties(java.util.Properties nullableProperties)
Creates a container with configured Hazelcast properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(HazelcastProperty property)
Returns true if value for given key is provided (either as a HazelcastProperty or a System property).java.lang.String
get(java.lang.String key)
Returns the value for the given key.boolean
getBoolean(HazelcastProperty property)
Returns the configured boolean value of aHazelcastProperty
.protected Config
getConfig()
double
getDouble(HazelcastProperty property)
Returns the configured double value of aHazelcastProperty
.<E extends java.lang.Enum>
EgetEnum(HazelcastProperty property, java.lang.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.java.lang.String
getString(HazelcastProperty property)
Returns the configured value of aHazelcastProperty
as String.java.util.Set<java.lang.String>
keySet()
Returns an immutable set of all keys in this HazelcastProperties.
-
-
-
Constructor Detail
-
HazelcastProperties
public HazelcastProperties(Config config)
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
public HazelcastProperties(java.util.Properties nullableProperties)
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 Detail
-
getConfig
protected Config getConfig()
-
keySet
public java.util.Set<java.lang.String> keySet()
Returns an immutable set of all keys in this HazelcastProperties.- Returns:
- set of keys
-
get
public java.lang.String get(java.lang.String key)
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:
java.lang.NullPointerException
- if key isnull
-
getString
public java.lang.String getString(HazelcastProperty property)
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
public boolean containsKey(HazelcastProperty property)
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
public boolean getBoolean(HazelcastProperty property)
Returns the configured boolean value of aHazelcastProperty
.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value as boolean
-
getInteger
public int getInteger(HazelcastProperty property)
Returns the configured int value of aHazelcastProperty
.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value as int
- Throws:
java.lang.NumberFormatException
- if the value cannot be parsed
-
getLong
public long getLong(HazelcastProperty property)
Returns the configured long value of aHazelcastProperty
.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value as long
- Throws:
java.lang.NumberFormatException
- if the value cannot be parsed
-
getFloat
public float getFloat(HazelcastProperty property)
Returns the configured float value of aHazelcastProperty
.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value as float
- Throws:
java.lang.NumberFormatException
- if the value cannot be parsed
-
getDouble
public double getDouble(HazelcastProperty property)
Returns the configured double value of aHazelcastProperty
.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value as double
- Throws:
java.lang.NumberFormatException
- if the value cannot be parsed
-
getNanos
public long getNanos(HazelcastProperty property)
Returns the configured value of aHazelcastProperty
converted to nanoseconds.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value in nanoseconds
- Throws:
java.lang.IllegalArgumentException
- if theHazelcastProperty
has noTimeUnit
-
getMillis
public long getMillis(HazelcastProperty property)
Returns the configured value of aHazelcastProperty
converted to milliseconds.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value in milliseconds
- Throws:
java.lang.IllegalArgumentException
- if theHazelcastProperty
has noTimeUnit
-
getPositiveMillisOrDefault
public long getPositiveMillisOrDefault(HazelcastProperty property)
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:
java.lang.IllegalArgumentException
- if theHazelcastProperty
has noTimeUnit
-
getPositiveMillisOrDefault
public 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.- 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:
java.lang.IllegalArgumentException
- if theHazelcastProperty
has noTimeUnit
-
getSeconds
public int getSeconds(HazelcastProperty property)
Returns the configured value of aHazelcastProperty
converted to seconds.- Parameters:
property
- theHazelcastProperty
to get the value from- Returns:
- the value in seconds
- Throws:
java.lang.IllegalArgumentException
- if theHazelcastProperty
has noTimeUnit
-
getEnum
public <E extends java.lang.Enum> E getEnum(HazelcastProperty property, java.lang.Class<E> enumClazz)
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:
java.lang.IllegalArgumentException
- if the enum value can't be found
-
-