Class MultimapBuilder.MultimapBuilderWithKeys<K0 extends @Nullable java.lang.Object>

  • Type Parameters:
    K0 - The upper bound on the key type of the generated multimap.
    Enclosing class:
    MultimapBuilder<K0 extends @Nullable java.lang.Object,​V0 extends @Nullable java.lang.Object>

    public abstract static class MultimapBuilder.MultimapBuilderWithKeys<K0 extends @Nullable java.lang.Object>
    extends java.lang.Object
    An intermediate stage in a MultimapBuilder in which the key-value collection map implementation has been specified, but the value collection implementation has not.
    Since:
    16.0
    • Method Detail

      • arrayListValues

        public final MultimapBuilder.ListMultimapBuilder<K0,​@Nullable java.lang.Object> arrayListValues​(int expectedValuesPerKey)
        Uses an ArrayList to store value collections, initialized to expect the specified number of values per key.
        Throws:
        java.lang.IllegalArgumentException - if expectedValuesPerKey < 0
      • linkedListValues

        public final MultimapBuilder.ListMultimapBuilder<K0,​@Nullable java.lang.Object> linkedListValues()
        Uses a LinkedList to store value collections.

        Performance note: ArrayList and ArrayDeque consistently outperform LinkedList except in certain rare and specific situations. Unless you have spent a lot of time benchmarking your specific needs, use one of those instead. (However, we do not currently offer a Multimap implementation based on ArrayDeque.)

      • hashSetValues

        public final MultimapBuilder.SetMultimapBuilder<K0,​@Nullable java.lang.Object> hashSetValues​(int expectedValuesPerKey)
        Uses a hash-based Set to store value collections, initialized to expect the specified number of values per key.
        Throws:
        java.lang.IllegalArgumentException - if expectedValuesPerKey < 0
      • linkedHashSetValues

        public final MultimapBuilder.SetMultimapBuilder<K0,​@Nullable java.lang.Object> linkedHashSetValues​(int expectedValuesPerKey)
        Uses an insertion-ordered hash-based Set to store value collections, initialized to expect the specified number of values per key.
        Throws:
        java.lang.IllegalArgumentException - if expectedValuesPerKey < 0
      • treeSetValues

        public final <V0 extends @Nullable java.lang.Object> MultimapBuilder.SortedSetMultimapBuilder<K0,​V0> treeSetValues​(java.util.Comparator<V0> comparator)
        Uses a TreeSet ordered by the specified comparator to store value collections.

        Multimaps generated by the resulting builder will not be serializable if comparator is not serializable.