Class ImmutableKeyValuePairs<K,​V>

  • Type Parameters:
    V - The type of the values contained in this.
    Direct Known Subclasses:
    Labels.ArrayBackedLabels

    @Immutable
    public abstract class ImmutableKeyValuePairs<K,​V>
    extends java.lang.Object
    An immutable set of key-value pairs.

    Key-value pairs are dropped for null or empty keys.

    Note: for subclasses of this, null keys will be removed, but if your key has another concept of being "empty", you'll need to remove them before calling sortAndFilter(Object[], boolean), assuming you don't want the "empty" keys to be kept in your collection.

    See Also:
    Labels, Attributes
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Map<K,​V> asMap()  
      protected java.util.List<java.lang.Object> data()  
      V get​(K key)
      Returns the value for the given key, or null if the key is not present.
      boolean isEmpty()  
      int size()  
      static java.util.List<java.lang.Object> sortAndFilter​(java.lang.Object[] data, boolean filterNullValues)
      Sorts and dedupes the key/value pairs in data.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • ImmutableKeyValuePairs

        public ImmutableKeyValuePairs()
    • Method Detail

      • data

        protected java.util.List<java.lang.Object> data()
      • size

        public int size()
      • isEmpty

        public boolean isEmpty()
      • asMap

        public java.util.Map<K,​V> asMap()
      • get

        @Nullable
        public V get​(K key)
        Returns the value for the given key, or null if the key is not present.
      • sortAndFilter

        public static java.util.List<java.lang.Object> sortAndFilter​(java.lang.Object[] data,
                                                                     boolean filterNullValues)
        Sorts and dedupes the key/value pairs in data. If filterNullValues is true, null values will be removed.
      • toString

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