Class Properties<K,V>

java.lang.Object
com.landawn.abacus.util.Properties<K,V>
Type Parameters:
K - the key type
V - the value type
All Implemented Interfaces:
Map<K,V>

public class Properties<K,V> extends Object implements Map<K,V>
Since:
0.8
Author:
Haiyang Li
  • Constructor Details

    • Properties

      public Properties()
  • Method Details

    • from

      public static <K, V> Properties<K,V> from(Map<? extends K,? extends V> map)
      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      map -
      Returns:
    • get

      public V get(Object propName)
      Specified by:
      get in interface Map<K,V>
      Parameters:
      propName -
      Returns:
    • get

      public <T> T get(Class<T> targetClass, Object propName)
      To avoid NullPointerException 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 interface Map<K,V>
      Parameters:
      propName -
      defaultValue - is returned if the specified propName 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 specified propName 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:
    • put

      public V put(K key, V value)
      Specified by:
      put in interface Map<K,V>
      Parameters:
      key -
      value -
      Returns:
    • putAll

      public void putAll(Map<? extends K,? extends V> m)
      Specified by:
      putAll in interface Map<K,V>
      Parameters:
      m -
    • putIfAbsent

      public V putIfAbsent(K key, V value)
      Put if absent.
      Specified by:
      putIfAbsent in interface Map<K,V>
      Parameters:
      key -
      value -
      Returns:
    • remove

      public V remove(Object key)
      Specified by:
      remove in interface Map<K,V>
      Parameters:
      key -
      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.
      Specified by:
      remove in interface Map<K,V>
      Parameters:
      key -
      value -
      Returns:
    • replace

      public V replace(K key, V value)
      Replaces the entry for the specified key only if it is currently mapped to some value.
      Specified by:
      replace in interface Map<K,V>
      Parameters:
      key -
      value -
      Returns:
    • 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.
      Specified by:
      replace in interface Map<K,V>
      Parameters:
      key -
      oldValue -
      newValue -
      Returns:
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<K,V>
      Parameters:
      key -
      Returns:
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<K,V>
      Parameters:
      value -
      Returns:
    • keySet

      public Set<K> keySet()
      Specified by:
      keySet in interface Map<K,V>
    • values

      public Collection<V> values()
      Specified by:
      values in interface Map<K,V>
    • entrySet

      public Set<Map.Entry<K,V>> entrySet()
      Specified by:
      entrySet in interface Map<K,V>
    • isEmpty

      public boolean isEmpty()
      Checks if is empty.
      Specified by:
      isEmpty in interface Map<K,V>
      Returns:
      true, if is empty
    • size

      public int size()
      Specified by:
      size in interface Map<K,V>
    • clear

      public void clear()
      Clear.
      Specified by:
      clear in interface Map<K,V>
    • copy

      public Properties<K,V> copy()
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map<K,V>
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Map<K,V>
      Overrides:
      equals in class Object
      Parameters:
      obj -
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object