Class ImmutableKeyValuePairs<K,​V>

  • Type Parameters:
    V - The type of the values contained in this.

    @Immutable
    public abstract class ImmutableKeyValuePairs<K,​V>
    extends 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.

    • Constructor Detail

      • ImmutableKeyValuePairs

        public ImmutableKeyValuePairs()
    • Method Detail

      • size

        public int size()
      • isEmpty

        public boolean isEmpty()
      • asMap

        public 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 List<Object> sortAndFilter​(Object[] data,
                                                 boolean filterNullValues)
        Sorts and dedupes the key/value pairs in data. If filterNullValues is true, null values will be removed. Keys must be Comparable.
      • sortAndFilter

        public static List<Object> sortAndFilter​(Object[] data,
                                                 boolean filterNullValues,
                                                 Comparator<?> keyComparator)
        Sorts and dedupes the key/value pairs in data. If filterNullValues is true, null values will be removed. Keys will be compared with the given Comparator.