Class HazelcastProperties

java.lang.Object
com.hazelcast.spi.properties.HazelcastProperties

public class HazelcastProperties extends Object
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
System properties documentaiton
  • 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

      public HazelcastProperties(ClientConfig clientConfig)
      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

      public HazelcastProperties(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 the { HazelcastProperty} values; properties are allowed to be null
  • Method Details

    • keySet

      public Set<String> keySet()
      Returns an immutable set of all keys in this HazelcastProperties.
      Returns:
      set of keys
    • get

      public String get(String key)
      Returns the value for the given key. If this HazelcastProperties object is initialized with a "compromised" { Properties} object (ie one where keys/values of types other than String have been inserted), then get on String keys mapped to non-String values will return null, 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 is null
    • getString

      public String getString(HazelcastProperty property)
      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

      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 - the { HazelcastProperty} to check
      Returns:
      true if the value was explicitly provided
    • getBoolean

      public boolean getBoolean(HazelcastProperty property)
      Returns the configured boolean value of a { HazelcastProperty}.
      Parameters:
      property - the { HazelcastProperty} to get the value from
      Returns:
      the value as boolean
    • getInteger

      public int getInteger(HazelcastProperty property)
      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

      public long getLong(HazelcastProperty property)
      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

      public float getFloat(HazelcastProperty property)
      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

      public double getDouble(HazelcastProperty property)
      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

      public long getNanos(HazelcastProperty property)
      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

      public long getMillis(HazelcastProperty property)
      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

      public long getPositiveMillisOrDefault(HazelcastProperty property)
      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

      public 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.
      Parameters:
      property - the { HazelcastProperty} to get the value from
      defaultValue - 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

      public int getSeconds(HazelcastProperty property)
      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

      public <E extends Enum> E getEnum(HazelcastProperty property, Class<E> enumClazz)
      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