Package com.landawn.abacus.util
Class Properties<K,V>
- java.lang.Object
-
- com.landawn.abacus.util.Properties<K,V>
-
-
Constructor Summary
Constructors Constructor Description Properties()
Instantiates a new properties.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear.boolean
containsKey(Object key)
boolean
containsValue(Object value)
Properties<K,V>
copy()
Set<Map.Entry<K,V>>
entrySet()
boolean
equals(Object obj)
static <K,V>
Properties<K,V>from(Map<? extends K,? extends V> map)
<T> T
get(Class<T> targetClass, Object propName)
To avoidNullPointerException
for primitive type if the target property is null or not set.V
get(Object propName)
<T> T
getOrDefault(Class<T> targetClass, Object propName, T defaultValue)
Gets the or default.V
getOrDefault(Object propName, V defaultValue)
Gets the or default.int
hashCode()
boolean
isEmpty()
Checks if is empty.Set<K>
keySet()
V
put(K key, V value)
void
putAll(Map<? extends K,? extends V> m)
V
putIfAbsent(K key, V value)
Put if absent.V
remove(Object key)
boolean
remove(Object key, Object value)
Removes the entry for the specified key only if it is currently mapped to the specified value.V
replace(K key, V value)
Replaces the entry for the specified key only if it is currently mapped to some value.boolean
replace(K key, V oldValue, V newValue)
Replaces the entry for the specified key only if currently mapped to the specified value.Properties<K,V>
set(K propName, V propValue)
int
size()
String
toString()
Collection<V>
values()
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, merge, replaceAll
-
-
-
-
Method Detail
-
from
public static <K,V> Properties<K,V> from(Map<? extends K,? extends V> map)
- Type Parameters:
K
- the key typeV
- the value type- Parameters:
map
-- Returns:
-
get
public <T> T get(Class<T> targetClass, Object propName)
To avoidNullPointerException
for primitive type if the target property is null or not set.- Type Parameters:
T
-- Parameters:
targetClass
-propName
-- Returns:
-
getOrDefault
public V getOrDefault(Object propName, V defaultValue)
Gets the or default.- Specified by:
getOrDefault
in interfaceMap<K,V>
- Parameters:
propName
-defaultValue
- is returned if the specifiedpropName
is not contained in this Properties instance or it's null.- Returns:
-
getOrDefault
public <T> T getOrDefault(Class<T> targetClass, Object propName, T defaultValue)
Gets the or default.- Type Parameters:
T
-- Parameters:
targetClass
-propName
-defaultValue
- is returned if the specifiedpropName
is not contained in this Properties instance or it's null.- Returns:
-
set
public Properties<K,V> set(K propName, V propValue)
- Parameters:
propName
-propValue
-- Returns:
-
putIfAbsent
public V putIfAbsent(K key, V value)
Put if absent.- Specified by:
putIfAbsent
in interfaceMap<K,V>
- Parameters:
key
-value
-- Returns:
-
remove
public boolean remove(Object key, Object value)
Removes the entry for the specified key only if it is currently mapped to the specified value.
-
replace
public V replace(K key, V value)
Replaces the entry for the specified key only if it is currently mapped to some value.
-
replace
public boolean replace(K key, V oldValue, V newValue)
Replaces the entry for the specified key only if currently mapped to the specified value.
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<K,V>
- Parameters:
key
-- Returns:
- true, if successful
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<K,V>
- Parameters:
value
-- Returns:
- true, if successful
-
isEmpty
public boolean isEmpty()
Checks if is empty.
-
copy
public Properties<K,V> copy()
- Returns:
-
hashCode
public int hashCode()
-
equals
public boolean equals(Object obj)
-
-