Class 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 the HazelcastProperty values; properties in config are allowed to be null
      • 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 the HazelcastProperty values; properties are allowed to be null
    • 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 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:
        java.lang.NullPointerException - if key is null
      • getString

        public java.lang.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
      • 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:
        java.lang.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:
        java.lang.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:
        java.lang.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:
        java.lang.NumberFormatException - if the value cannot be parsed
      • 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:
        java.lang.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:
        java.lang.IllegalArgumentException - if the HazelcastProperty has no TimeUnit
      • getEnum

        public <E extends java.lang.Enum> E getEnum​(HazelcastProperty property,
                                                    java.lang.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:
        java.lang.IllegalArgumentException - if the enum value can't be found