Class Map<K,​V>

    • Constructor Summary

      Constructors 
      Constructor Description
      Map​(java.util.Map<java.lang.Object,​java.lang.Object> map, TypeDescriptor<?>[] generics)
      Creates a map wrapper.
      Map​(TypeDescriptor<?>[] types)
      Creates a new map.
      Map​(TypeDescriptor<?>[] types, int size)
      Creates a new map.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.Object key, V value)
      Adds a key-value pair to this map and overrides existing mappings.
      V at​(java.lang.Object key)
      Returns the value assigned to key.
      static java.lang.Object checkConvertEmpty​(TypeDescriptor<?> type, java.lang.Object value)
      Converts value to an empty map with parameter types from type, if type is a map and value is an empty map instance.
      void clear()
      Clears all entries.
      Map<K,​V> cloneMap()
      Clones this map.
      boolean containsKey​(java.lang.Object key)
      Returns whether this map contains a mapping for the given key.
      static Map<?,​?> convert​(Sequence<?> sequence)
      Converts the given sequence into a map.
      boolean equals​(java.lang.Object object)  
      V get​(java.lang.Object key)
      Returns the value assigned to key.
      V get​(java.lang.Object key, V deflt)
      Returns the value assigned to key, if there is none deflt.
      int getDimensionCount()
      Returns the number of dimensions of T.
      TypeDescriptor<?> getDimensionType​(int index)
      Returns the type of the specified dimension of T.
      Set<K> getKeys()
      Returns the keys of this map.
      V getOrAdd​(java.lang.Object key, V deflt)
      Returns the value assigned to key, if there is none it associates key with deflt, i.e., adds deflt.
      int getSize()
      Returns the size of the map.
      static java.lang.String getStringValue​(java.util.Map<?,​?> map, IStringValueProvider.StringComparator comparator)
      Returns the string value of the given map .
      java.lang.String getStringValue​(IStringValueProvider.StringComparator comparator)
      Returns the string value of this object.
      TypeDescriptor<?> getType()
      Returns the actual type including generics.
      Set<V> getValues()
      Returns the values of this map.
      int hashCode()  
      private static boolean isAny​(TypeDescriptor<?> type)
      Returns whether type is Any.
      private static boolean isAnyMap​(Map<?,​?> map)
      Returns whether map is an map.
      boolean isEmpty()
      Returns whether the map is empty.
      Set<K> keys()
      Returns the keys of this map.
      boolean notEmpty()
      Returns whether the map is not empty.
      void put​(java.lang.Object key, V value)
      Adds a key-value pair to this map and overrides existing mappings.
      void remove​(java.lang.Object key)
      Removes the given key from the map.
      Sequence<V> sortByKeys​(ExpressionEvaluator evaluator)
      Sorts values in this map according to keys.
      java.util.Map<java.lang.Object,​java.lang.Object> toMap()
      Converts back to a map for utilizing this with external classes.
      java.util.Map<K,​V> toMappedMap()
      Translates this VIL map to a Java map.
      java.lang.String toString()  
      Set<V> values()
      Returns the values of this map.
      • Methods inherited from class java.lang.Object

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

      • DEFAULT

        public static final java.util.Map<?,​?> DEFAULT
      • map

        private java.util.Map<java.lang.Object,​java.lang.Object> map
    • Constructor Detail

      • Map

        Map​(TypeDescriptor<?>[] types)
        Creates a new map.
        Parameters:
        types - the parameter types of this map
      • Map

        Map​(TypeDescriptor<?>[] types,
            int size)
        Creates a new map.
        Parameters:
        types - the parameter types of this map
        size - the initial size of this map
      • Map

        public Map​(java.util.Map<java.lang.Object,​java.lang.Object> map,
                   TypeDescriptor<?>[] generics)
        Creates a map wrapper.
        Parameters:
        map - the map to be wrapped
        generics - the generic types in map
    • Method Detail

      • at

        public V at​(java.lang.Object key)
        Returns the value assigned to key.
        Parameters:
        key - the key to search the value for
        Returns:
        the value for key (may be null)
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Returns whether this map contains a mapping for the given key.
        Parameters:
        key - the key to search for
        Returns:
        true if key is included, false else
      • get

        public V get​(java.lang.Object key)
        Returns the value assigned to key.
        Parameters:
        key - the key to search the value for
        Returns:
        the value for key (may be null)
      • get

        public V get​(java.lang.Object key,
                     V deflt)
        Returns the value assigned to key, if there is none deflt.
        Parameters:
        key - the key to search the value for
        deflt - the default value if key does not exist
        Returns:
        the value for key (deflt if no key-value mapping is defined)
      • getOrAdd

        public V getOrAdd​(java.lang.Object key,
                          V deflt)
        Returns the value assigned to key, if there is none it associates key with deflt, i.e., adds deflt.
        Parameters:
        key - the key to search the value for
        deflt - the default value if key does not exist, a key-value mapping will be added
        Returns:
        the value for key (deflt if no key-value mapping is defined)
      • keys

        public Set<K> keys()
        Returns the keys of this map.
        Returns:
        the keys
      • getKeys

        public Set<K> getKeys()
        Returns the keys of this map.
        Returns:
        the keys
      • values

        public Set<V> values()
        Returns the values of this map.
        Returns:
        the values
      • getValues

        public Set<V> getValues()
        Returns the values of this map.
        Returns:
        the values
      • add

        public void add​(java.lang.Object key,
                        V value)
        Adds a key-value pair to this map and overrides existing mappings.
        Parameters:
        key - the key for the mapping (null is ignored)
        value - the value of the mapping
      • put

        public void put​(java.lang.Object key,
                        V value)
        Adds a key-value pair to this map and overrides existing mappings.
        Parameters:
        key - the key for the mapping (null is ignored)
        value - the value of the mapping
      • isAnyMap

        private static final boolean isAnyMap​(Map<?,​?> map)
        Returns whether map is an map.
        Parameters:
        map - the map to test
        Returns:
        true if it is an map, false else
      • isAny

        private static final boolean isAny​(TypeDescriptor<?> type)
        Returns whether type is Any.
        Parameters:
        type - the type to test
        Returns:
        true if type is Any, false else
      • remove

        public void remove​(java.lang.Object key)
        Removes the given key from the map.
        Parameters:
        key - the key to be removed
      • clear

        public void clear()
        Clears all entries.
      • getDimensionCount

        public int getDimensionCount()
        Returns the number of dimensions of T.
        Returns:
        the number of dimensions
      • getSize

        public int getSize()
        Returns the size of the map.
        Returns:
        the size of the map
      • getDimensionType

        public TypeDescriptor<?> getDimensionType​(int index)
        Returns the type of the specified dimension of T.
        Parameters:
        index - the 0-based index of the dimension
        Returns:
        the actual type of the dimension
      • convert

        public static Map<?,​?> convert​(Sequence<?> sequence)
                                      throws VilException
        Converts the given sequence into a map.
        Parameters:
        sequence - the sequence to be converted
        Returns:
        the resulting map
        Throws:
        VilException - in case that types or dimensions cannot be converted
      • getStringValue

        public java.lang.String getStringValue​(IStringValueProvider.StringComparator comparator)
        Description copied from interface: IStringValueProvider
        Returns the string value of this object.
        Specified by:
        getStringValue in interface IStringValueProvider
        Parameters:
        comparator - if the sequence of elements, e.g., in case of collections, shall be ordered according to the comparator, null if the original sequence shall be returned
        Returns:
        the string value
      • getStringValue

        public static java.lang.String getStringValue​(java.util.Map<?,​?> map,
                                                      IStringValueProvider.StringComparator comparator)
        Returns the string value of the given map .
        Parameters:
        map - the map to be turned into a String
        comparator - if the sequence of elements, e.g., in case of collections, shall be ordered according to the comparator, null if the original sequence shall be returned
        Returns:
        the string value
      • checkConvertEmpty

        public static java.lang.Object checkConvertEmpty​(TypeDescriptor<?> type,
                                                         java.lang.Object value)
        Converts value to an empty map with parameter types from type, if type is a map and value is an empty map instance. This is needed for initialization.
        Parameters:
        type - the (target) type to be checked
        value - the value to be checked
        Returns:
        value or an empty map of the given types
      • equals

        public boolean equals​(java.lang.Object object)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toMap

        public java.util.Map<java.lang.Object,​java.lang.Object> toMap()
        Converts back to a map for utilizing this with external classes.
        Returns:
        the internal map
      • sortByKeys

        public Sequence<V> sortByKeys​(ExpressionEvaluator evaluator)
                               throws VilException
        Sorts values in this map according to keys.
        Parameters:
        evaluator - the evaluator
        Returns:
        the map values sorted according to the keys
        Throws:
        VilException - in case that evaluating fails
      • toString

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

        public java.util.Map<K,​V> toMappedMap()
        Translates this VIL map to a Java map.
        Returns:
        the translated map
      • isEmpty

        public boolean isEmpty()
        Returns whether the map is empty.
        Returns:
        true for empty, false else
      • notEmpty

        public boolean notEmpty()
        Returns whether the map is not empty.
        Returns:
        false for empty, true else
      • cloneMap

        public Map<K,​V> cloneMap()
        Clones this map.
        Returns:
        the clone