Class Properties


  • public class Properties
    extends java.lang.Object
    Properties that maps property keys to values. The properties cannot contain duplicate property names; each property name can map to at most one value.
    Author:
    Philipp Ossler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​java.lang.Object> properties  
    • Constructor Summary

      Constructors 
      Constructor Description
      Properties()  
      Properties​(java.util.Map<java.lang.String,​java.lang.Object> properties)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> void addListItem​(PropertyListKey<T> property, T value)
      Append the value to the list to which the specified property key is mapped.
      boolean contains​(PropertyKey<?> property)
      Returns true if this properties contains a mapping for the specified property key.
      boolean contains​(PropertyListKey<?> property)
      Returns true if this properties contains a mapping for the specified property key.
      boolean contains​(PropertyMapKey<?,​?> property)
      Returns true if this properties contains a mapping for the specified property key.
      <T> T get​(PropertyKey<T> property)
      Returns the value to which the specified property key is mapped, or null if this properties contains no mapping for the property key.
      <T> java.util.List<T> get​(PropertyListKey<T> property)
      Returns the list to which the specified property key is mapped, or an empty list if this properties contains no mapping for the property key.
      <K,​V>
      java.util.Map<K,​V>
      get​(PropertyMapKey<K,​V> property)
      Returns the map to which the specified property key is mapped, or an empty map if this properties contains no mapping for the property key.
      <K,​V>
      void
      putMapEntry​(PropertyMapKey<K,​V> property, K key, V value)
      Insert the value to the map to which the specified property key is mapped.
      <T> void set​(PropertyKey<T> property, T value)
      Associates the specified value with the specified property key.
      <T> void set​(PropertyListKey<T> property, java.util.List<T> value)
      Associates the specified list with the specified property key.
      <K,​V>
      void
      set​(PropertyMapKey<K,​V> property, java.util.Map<K,​V> value)
      Associates the specified map with the specified property key.
      java.util.Map<java.lang.String,​java.lang.Object> toMap()
      Returns a map view of this properties.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • properties

        protected final java.util.Map<java.lang.String,​java.lang.Object> properties
    • Constructor Detail

      • Properties

        public Properties()
      • Properties

        public Properties​(java.util.Map<java.lang.String,​java.lang.Object> properties)
    • Method Detail

      • get

        public <T> T get​(PropertyKey<T> property)
        Returns the value to which the specified property key is mapped, or null if this properties contains no mapping for the property key.
        Parameters:
        property - the property key whose associated value is to be returned
        Returns:
        the value to which the specified property key is mapped, or null if this properties contains no mapping for the property key
      • get

        public <T> java.util.List<T> get​(PropertyListKey<T> property)
        Returns the list to which the specified property key is mapped, or an empty list if this properties contains no mapping for the property key. Note that the empty list is not mapped to the property key.
        Parameters:
        property - the property key whose associated list is to be returned
        Returns:
        the list to which the specified property key is mapped, or an empty list if this properties contains no mapping for the property key
        See Also:
        addListItem(PropertyListKey, Object)
      • get

        public <K,​V> java.util.Map<K,​V> get​(PropertyMapKey<K,​V> property)
        Returns the map to which the specified property key is mapped, or an empty map if this properties contains no mapping for the property key. Note that the empty map is not mapped to the property key.
        Parameters:
        property - the property key whose associated map is to be returned
        Returns:
        the map to which the specified property key is mapped, or an empty map if this properties contains no mapping for the property key
        See Also:
        putMapEntry(PropertyMapKey, Object, Object)
      • set

        public <T> void set​(PropertyKey<T> property,
                            T value)
        Associates the specified value with the specified property key. If the properties previously contained a mapping for the property key, the old value is replaced by the specified value.
        Type Parameters:
        T - the type of the value
        Parameters:
        property - the property key with which the specified value is to be associated
        value - the value to be associated with the specified property key
      • set

        public <T> void set​(PropertyListKey<T> property,
                            java.util.List<T> value)
        Associates the specified list with the specified property key. If the properties previously contained a mapping for the property key, the old value is replaced by the specified list.
        Type Parameters:
        T - the type of elements in the list
        Parameters:
        property - the property key with which the specified list is to be associated
        value - the list to be associated with the specified property key
      • set

        public <K,​V> void set​(PropertyMapKey<K,​V> property,
                                    java.util.Map<K,​V> value)
        Associates the specified map with the specified property key. If the properties previously contained a mapping for the property key, the old value is replaced by the specified map.
        Type Parameters:
        K - the type of keys maintained by the map
        V - the type of mapped values
        Parameters:
        property - the property key with which the specified map is to be associated
        value - the map to be associated with the specified property key
      • addListItem

        public <T> void addListItem​(PropertyListKey<T> property,
                                    T value)
        Append the value to the list to which the specified property key is mapped. If this properties contains no mapping for the property key, the value append to a new list witch is associate the the specified property key.
        Type Parameters:
        T - the type of elements in the list
        Parameters:
        property - the property key whose associated list is to be added
        value - the value to be appended to list
      • putMapEntry

        public <K,​V> void putMapEntry​(PropertyMapKey<K,​V> property,
                                            K key,
                                            V value)
        Insert the value to the map to which the specified property key is mapped. If this properties contains no mapping for the property key, the value insert to a new map witch is associate the the specified property key.
        Type Parameters:
        K - the type of keys maintained by the map
        V - the type of mapped values
        Parameters:
        property - the property key whose associated list is to be added
        value - the value to be appended to list
      • contains

        public boolean contains​(PropertyKey<?> property)
        Returns true if this properties contains a mapping for the specified property key.
        Parameters:
        property - the property key whose presence is to be tested
        Returns:
        true if this properties contains a mapping for the specified property key
      • contains

        public boolean contains​(PropertyListKey<?> property)
        Returns true if this properties contains a mapping for the specified property key.
        Parameters:
        property - the property key whose presence is to be tested
        Returns:
        true if this properties contains a mapping for the specified property key
      • contains

        public boolean contains​(PropertyMapKey<?,​?> property)
        Returns true if this properties contains a mapping for the specified property key.
        Parameters:
        property - the property key whose presence is to be tested
        Returns:
        true if this properties contains a mapping for the specified property key
      • toMap

        public java.util.Map<java.lang.String,​java.lang.Object> toMap()
        Returns a map view of this properties. Changes to the map are not reflected to the properties.
        Returns:
        a map view of this properties
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object