Package cl.obcom.desktopfx.util
Class Settings
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<String,
Object>
Implements a
HashMap
with additional functionality.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
ConstructorDescriptionSettings()
Constructs an emptySettings
instance with the default initial capacity and load factor.Settings
(int initialCapacity) Constructs an emptySettings
instance with the specified initial capacity and a default load factor.Settings
(int initialCapacity, float loadFactor) Constructs an emptySettings
instance with the specified initial capacity and load factor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPropertyChangeListener
(String key, PropertyChangeListener listener) Adds alistener
to the list of change listeners of this map.void
clear()
Removes all of the mappings from this map.Returns the value to which the specified object key is mapped.Returns the value to which the specified string key is mapped.Returns the object value of a mapping ordefval
if not defined.getBigDecimal
(String key) Returns the decimal value of a mapping orZERO
if not defined.getBigDecimal
(String key, BigDecimal defval) Returns the decimal value of a mapping ordefval
if not defined.boolean
getBoolean
(String key) Returns the boolean value of a mapping orfalse
if not defined.boolean
getBoolean
(String key, boolean defval) Returns the boolean value of the key ordefval
if not defined.Returns the date value of a mapping ornull
if not defined.Returns the date value of a mapping ordefval
if not defined.double
Returns the double value of a mapping or0
if not defined.double
Returns the double value of a mapping ordefval
if not defined.int
Returns the integer value of a mapping or0
if not defined.int
Returns the integer value of a mapping ordefval
if not defined.long
Returns the long value of a mapping or0
if not defined.long
Returns the long value of a mapping ordefval
if not defined.Returns the string value of a mapping ornull
if not defined.Returns the string value of a mapping ordefval
if not defined.Associates the specified value with the specified key in this map.void
Copies all of the mappings from the specifiedmap
to this map.void
putAll
(Properties properties) Copies all of the mappings ofproperties
to this map.void
putDefaults
(Settings settings) Adds the mappings ofsettings
not contained in this map.void
putDefaults
(Properties properties) Adds the mappings ofproperties
not contained in this map.void
Copies all of the mappings of supplied map to this map.Removes the mapping for the specified key from this map if present.void
removePropertyChangeListener
(String key, PropertyChangeListener listener) Removes alistener
from the list of change listeners of this map.Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, newHashMap, putIfAbsent, remove, replace, replace, replaceAll, size, values
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Constructor Details
-
Settings
public Settings()Constructs an emptySettings
instance with the default initial capacity and load factor. -
Settings
public Settings(int initialCapacity, float loadFactor) Constructs an emptySettings
instance with the specified initial capacity and load factor.- Parameters:
initialCapacity
- the initial capacity.loadFactor
- the load factor.- Throws:
IllegalArgumentException
- if the initial capacity is negative or the load factor is nonpositive.
-
Settings
public Settings(int initialCapacity) Constructs an emptySettings
instance with the specified initial capacity and a default load factor.- Parameters:
initialCapacity
- the initial capacity.- Throws:
IllegalArgumentException
- if the initial capacity is negative.
-
-
Method Details
-
put
Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced. Registered listeners are notified of the changed mappings.- Specified by:
put
in interfaceMap<String,
Object> - Overrides:
put
in classHashMap<String,
Object> - Parameters:
key
- the key with which the specified value is to be associated.value
- value to be associated with the specified key.- Returns:
- the previous value associated with
key
ornull
. - Throws:
NullPointerException
- if an argument isnull
.
-
putAll
Copies all of the mappings from the specifiedmap
to this map. These mappings will replace any mappings that this map had for any of the keys currently in the specified map. Registered listeners are notified of the changed mappings. -
putAll
Copies all of the mappings ofproperties
to this map. These mappings replace any mappings that this map had for any of the keys currently in the specifiedProperties
. Registered listeners are notified of the changed mappings.- Parameters:
properties
- the properties to copy to this map.- Throws:
NullPointerException
- ifproperties
isnull
.
-
putMap
Copies all of the mappings of supplied map to this map. These mappings replace any mappings that this map had for any of the keys currently in the specifiedmap
. Registered listeners are notified of the changed mappings.- Parameters:
map
- the map to copy to this map.- Throws:
NullPointerException
- ifmap
isnull
.
-
putDefaults
Adds the mappings ofsettings
not contained in this map. The mappings that currently exist in this map are not changed. Registered listeners are notified of the changed mappings.- Parameters:
settings
- the settings to add to this map.- Throws:
NullPointerException
- ifsettings
isnull
.
-
putDefaults
Adds the mappings ofproperties
not contained in this map. The mappings that currently exist in this map are not changed. Registered listeners are notified of the changed mappings.- Parameters:
properties
- the properties to add to this map.- Throws:
NullPointerException
- ifproperties
isnull
.
-
remove
Removes the mapping for the specified key from this map if present. Registered listeners are notified of the removed mappings. -
clear
public void clear()Removes all of the mappings from this map. The map will be empty after this call returns. Registered listeners are notified of the removed mappings. -
get
Returns the value to which the specified object key is mapped. -
get
Returns the value to which the specified string key is mapped.- Parameters:
key
- the string key of the mapping.- Returns:
- the object value or
null
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.
-
get
Returns the object value of a mapping ordefval
if not defined.- Parameters:
key
- the key of the mapping.defval
- the default value.- Returns:
- the object value or
defval
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.
-
getString
Returns the string value of a mapping ornull
if not defined.- Parameters:
key
- the key of the mapping.- Returns:
- the string value or
null
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.
-
getString
Returns the string value of a mapping ordefval
if not defined.- Parameters:
key
- the key of the mapping.defval
- the default value.- Returns:
- the string value or
defval
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.
-
getDouble
Returns the double value of a mapping or0
if not defined.- Parameters:
key
- the key of the mapping.- Returns:
- the double value or
0
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.NumberFormatException
- if the value is not aDouble
.
-
getDouble
Returns the double value of a mapping ordefval
if not defined.- Parameters:
key
- the key of the mapping.defval
- the default value.- Returns:
- the double value or
defval
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.NumberFormatException
- if the value is not aDouble
.
-
getInt
Returns the integer value of a mapping or0
if not defined.- Parameters:
key
- the key of the mapping.- Returns:
- the integer value or
0
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.NumberFormatException
- if the value is not anInteger
.
-
getInt
Returns the integer value of a mapping ordefval
if not defined.- Parameters:
key
- the key of the mapping.defval
- the default value.- Returns:
- the integer value or
defval
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.NumberFormatException
- if the value is not anInteger
.
-
getLong
Returns the long value of a mapping or0
if not defined.- Parameters:
key
- the key of the mapping.- Returns:
- the long value or
0
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.NumberFormatException
- if the value is not aLong
.
-
getLong
Returns the long value of a mapping ordefval
if not defined.- Parameters:
key
- the key of the mapping.defval
- the default value.- Returns:
- the long value or
defval
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.NumberFormatException
- if the value is not aLong
.
-
getBigDecimal
Returns the decimal value of a mapping orZERO
if not defined.- Parameters:
key
- the key of the mapping.- Returns:
- the decimal value or
ZERO
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.NumberFormatException
- if the value is not aBigDecimal
.
-
getBigDecimal
Returns the decimal value of a mapping ordefval
if not defined.- Parameters:
key
- the key of the mapping.defval
- the default value.- Returns:
- the decimal value or
defval
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.NumberFormatException
- if the value is not aBigDecimal
.
-
getBoolean
Returns the boolean value of a mapping orfalse
if not defined.- Parameters:
key
- the key of the mapping.- Returns:
- the boolean value or
false
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.ClassCastException
- if the value is not aBoolean
.
-
getBoolean
Returns the boolean value of the key ordefval
if not defined.- Parameters:
key
- the key of the mapping.defval
- the default value.- Returns:
- the boolean value or
defval
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.
-
getDate
Returns the date value of a mapping ornull
if not defined.- Parameters:
key
- the key of the mapping.- Returns:
- the date value or
null
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.IllegalArgumentException
- if the value is not aDate
.
-
getDate
Returns the date value of a mapping ordefval
if not defined.- Parameters:
key
- the key of the mapping.defval
- the default value.- Returns:
- the date value or
defval
if not defined. - Throws:
NullPointerException
- ifkey
isnull
.IllegalArgumentException
- if the value is not aDate
.
-
addPropertyChangeListener
Adds alistener
to the list of change listeners of this map.- Parameters:
key
- the key of the mapping.listener
- the property change listener.- Throws:
NullPointerException
- if an argument isnull
.
-
removePropertyChangeListener
Removes alistener
from the list of change listeners of this map.- Parameters:
key
- the key of the mapping.listener
- the property change listener.- Throws:
NullPointerException
- if an argument isnull
.
-