Package picocli

Class CommandLine.Model.CaseAwareLinkedMap<K,​V>

  • Type Parameters:
    V - type of the value
    All Implemented Interfaces:
    java.util.Map<K,​V>
    Enclosing class:
    CommandLine.Model

    static class CommandLine.Model.CaseAwareLinkedMap<K,​V>
    extends java.util.AbstractMap<K,​V>
    This class provides a case-aware Linked HashMap. Supports both case-sensitive and case-insensitive modes.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) class  CommandLine.Model.CaseAwareLinkedMap.CaseAwareKeySet  
      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean caseInsensitive  
      private java.util.HashMap<K,​K> keyMap  
      private java.util.Set<K> keySet  
      private java.util.Locale locale  
      private java.util.LinkedHashMap<K,​V> targetMap  
    • Constructor Summary

      Constructors 
      Constructor Description
      CaseAwareLinkedMap()
      Constructs an empty CaseAwareLinkedMap instance with Locale.ENGLISH.
      CaseAwareLinkedMap​(java.util.Locale locale)
      Constructs an empty CaseAwareLinkedMap instance with the specified Locale.
      CaseAwareLinkedMap​(CommandLine.Model.CaseAwareLinkedMap<? extends K,​? extends V> map)
      Constructs a CaseAwareLinkedMap instance with the same mappings, case-sensitivity and locale as the specified map.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      boolean containsKey​(java.lang.Object key)  
      boolean containsValue​(java.lang.Object value)  
      java.util.Set<java.util.Map.Entry<K,​V>> entrySet()  
      V get​(java.lang.Object key)  
      K getCaseSensitiveKey​(K caseInsensitiveKey)
      Returns the case-sensitive key of the specified case-insensitive key if isCaseSensitive().
      java.util.Locale getLocale()
      Returns the locale of the map.
      (package private) static boolean isCaseConvertible​(java.lang.Class<?> clazz)  
      boolean isCaseInsensitive()
      Returns the case-insensitivity of the map.
      java.util.Set<K> keySet()  
      V put​(K key, V value)  
      V remove​(java.lang.Object key)  
      void setCaseInsensitive​(boolean caseInsensitive)
      Sets the case-insensitivity of the map.
      int size()  
      private K toLowerCase​(java.lang.Object caseSensitiveKey)  
      java.util.Collection<V> values()  
      • Methods inherited from class java.util.AbstractMap

        clone, equals, hashCode, isEmpty, putAll, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Field Detail

      • targetMap

        private final java.util.LinkedHashMap<K,​V> targetMap
      • keyMap

        private final java.util.HashMap<K,​K> keyMap
      • keySet

        private final java.util.Set<K> keySet
      • caseInsensitive

        private boolean caseInsensitive
      • locale

        private final java.util.Locale locale
    • Constructor Detail

      • CaseAwareLinkedMap

        public CaseAwareLinkedMap()
        Constructs an empty CaseAwareLinkedMap instance with Locale.ENGLISH.
      • CaseAwareLinkedMap

        public CaseAwareLinkedMap​(java.util.Locale locale)
        Constructs an empty CaseAwareLinkedMap instance with the specified Locale.
        Parameters:
        locale - the locale to convert character cases
      • CaseAwareLinkedMap

        public CaseAwareLinkedMap​(CommandLine.Model.CaseAwareLinkedMap<? extends K,​? extends V> map)
        Constructs a CaseAwareLinkedMap instance with the same mappings, case-sensitivity and locale as the specified map.
        Parameters:
        map - the map whose mappings, case-sensitivity and locale are to be placed in this map
        Throws:
        java.lang.NullPointerException - if the specified map is null
    • Method Detail

      • isCaseConvertible

        static boolean isCaseConvertible​(java.lang.Class<?> clazz)
      • toLowerCase

        private K toLowerCase​(java.lang.Object caseSensitiveKey)
      • isCaseInsensitive

        public boolean isCaseInsensitive()
        Returns the case-insensitivity of the map.
      • setCaseInsensitive

        public void setCaseInsensitive​(boolean caseInsensitive)
        Sets the case-insensitivity of the map.
      • getLocale

        public java.util.Locale getLocale()
        Returns the locale of the map.
      • getCaseSensitiveKey

        public K getCaseSensitiveKey​(K caseInsensitiveKey)
        Returns the case-sensitive key of the specified case-insensitive key if isCaseSensitive(). Otherwise, the specified case-insensitive key is returned.
      • size

        public int size()
        Specified by:
        size in interface java.util.Map<K,​V>
        Overrides:
        size in class java.util.AbstractMap<K,​V>
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map<K,​V>
        Overrides:
        containsKey in class java.util.AbstractMap<K,​V>
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Specified by:
        containsValue in interface java.util.Map<K,​V>
        Overrides:
        containsValue in class java.util.AbstractMap<K,​V>
      • get

        public V get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map<K,​V>
        Overrides:
        get in class java.util.AbstractMap<K,​V>
      • put

        public V put​(K key,
                     V value)
        Specified by:
        put in interface java.util.Map<K,​V>
        Overrides:
        put in class java.util.AbstractMap<K,​V>
      • remove

        public V remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map<K,​V>
        Overrides:
        remove in class java.util.AbstractMap<K,​V>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<K,​V>
        Overrides:
        clear in class java.util.AbstractMap<K,​V>
      • keySet

        public java.util.Set<K> keySet()
        Specified by:
        keySet in interface java.util.Map<K,​V>
        Overrides:
        keySet in class java.util.AbstractMap<K,​V>
      • values

        public java.util.Collection<V> values()
        Specified by:
        values in interface java.util.Map<K,​V>
        Overrides:
        values in class java.util.AbstractMap<K,​V>
      • entrySet

        public java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<K,​V>
        Specified by:
        entrySet in class java.util.AbstractMap<K,​V>