com.hazelcast.spi.properties

## Class HazelcastProperties

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

-     public class HazelcastProperties
      extends Object

  Container for configured Hazelcast properties (`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:
    System properties documentaiton

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HazelcastProperties(Config config)` Creates a container with configured Hazelcast properties.
    `HazelcastProperties(Properties nullableProperties)` Creates a container with configured Hazelcast properties.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `containsKey(HazelcastProperty property)` Returns true if value for given key is provided (either as a HazelcastProperty or a System property).
    `String` | `get(String key)` 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> E` | `getEnum(HazelcastProperty property, Class<E> enumClazz)` Returns the configured enum value of a `GroupProperty`.
    `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.
    `String` | `getString(HazelcastProperty property)` Returns the configured value of a `HazelcastProperty` as String.
    `Set<String>` | `keySet()` Returns an immutable set of all keys in this HazelcastProperties.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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 the `HazelcastProperty` values; properties in config are allowed to be `null`

    - #### 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 Detail

    - #### 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.
      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 `GroupProperty`.

      The case of the enum is ignored.

      Parameters:
        `property` - the `GroupProperty` to get the value from
      Returns:
        the enum
      Throws:
        `IllegalArgumentException` - if the enum value can't be found

Copyright © 2019. All rights reserved.