001/* 002 * Copyright (C) 2009 The Guava Authors 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.google.common.collect; 018 019import static com.google.common.base.Preconditions.checkNotNull; 020 021import com.google.common.annotations.Beta; 022import com.google.common.annotations.GwtCompatible; 023import com.google.common.annotations.GwtIncompatible; 024import com.google.common.base.MoreObjects; 025import com.google.errorprone.annotations.CanIgnoreReturnValue; 026import com.google.errorprone.annotations.DoNotCall; 027import com.google.errorprone.annotations.concurrent.LazyInit; 028import com.google.j2objc.annotations.RetainedWith; 029import com.google.j2objc.annotations.Weak; 030import java.io.IOException; 031import java.io.InvalidObjectException; 032import java.io.ObjectInputStream; 033import java.io.ObjectOutputStream; 034import java.util.Arrays; 035import java.util.Collection; 036import java.util.Comparator; 037import java.util.Map; 038import java.util.Map.Entry; 039import java.util.function.Function; 040import java.util.stream.Collector; 041import java.util.stream.Stream; 042import org.checkerframework.checker.nullness.qual.Nullable; 043 044/** 045 * A {@link SetMultimap} whose contents will never change, with many other important properties 046 * detailed at {@link ImmutableCollection}. 047 * 048 * <p>See the Guava User Guide article on <a href= 049 * "https://github.com/google/guava/wiki/ImmutableCollectionsExplained"> immutable collections</a>. 050 * 051 * @author Mike Ward 052 * @since 2.0 053 */ 054@GwtCompatible(serializable = true, emulated = true) 055public class ImmutableSetMultimap<K, V> extends ImmutableMultimap<K, V> 056 implements SetMultimap<K, V> { 057 /** 058 * Returns a {@link Collector} that accumulates elements into an {@code ImmutableSetMultimap} 059 * whose keys and values are the result of applying the provided mapping functions to the input 060 * elements. 061 * 062 * <p>For streams with defined encounter order (as defined in the Ordering section of the {@link 063 * java.util.stream} Javadoc), that order is preserved, but entries are <a 064 * href="ImmutableMultimap.html#iteration">grouped by key</a>. 065 * 066 * <p>Example: 067 * 068 * <pre>{@code 069 * static final Multimap<Character, String> FIRST_LETTER_MULTIMAP = 070 * Stream.of("banana", "apple", "carrot", "asparagus", "cherry") 071 * .collect(toImmutableSetMultimap(str -> str.charAt(0), str -> str.substring(1))); 072 * 073 * // is equivalent to 074 * 075 * static final Multimap<Character, String> FIRST_LETTER_MULTIMAP = 076 * new ImmutableSetMultimap.Builder<Character, String>() 077 * .put('b', "anana") 078 * .putAll('a', "pple", "sparagus") 079 * .putAll('c', "arrot", "herry") 080 * .build(); 081 * }</pre> 082 * 083 * @since 21.0 084 */ 085 public static <T, K, V> Collector<T, ?, ImmutableSetMultimap<K, V>> toImmutableSetMultimap( 086 Function<? super T, ? extends K> keyFunction, 087 Function<? super T, ? extends V> valueFunction) { 088 return CollectCollectors.toImmutableSetMultimap(keyFunction, valueFunction); 089 } 090 091 /** 092 * Returns a {@code Collector} accumulating entries into an {@code ImmutableSetMultimap}. Each 093 * input element is mapped to a key and a stream of values, each of which are put into the 094 * resulting {@code Multimap}, in the encounter order of the stream and the encounter order of the 095 * streams of values. 096 * 097 * <p>Example: 098 * 099 * <pre>{@code 100 * static final ImmutableSetMultimap<Character, Character> FIRST_LETTER_MULTIMAP = 101 * Stream.of("banana", "apple", "carrot", "asparagus", "cherry") 102 * .collect( 103 * flatteningToImmutableSetMultimap( 104 * str -> str.charAt(0), 105 * str -> str.substring(1).chars().mapToObj(c -> (char) c)); 106 * 107 * // is equivalent to 108 * 109 * static final ImmutableSetMultimap<Character, Character> FIRST_LETTER_MULTIMAP = 110 * ImmutableSetMultimap.<Character, Character>builder() 111 * .putAll('b', Arrays.asList('a', 'n', 'a', 'n', 'a')) 112 * .putAll('a', Arrays.asList('p', 'p', 'l', 'e')) 113 * .putAll('c', Arrays.asList('a', 'r', 'r', 'o', 't')) 114 * .putAll('a', Arrays.asList('s', 'p', 'a', 'r', 'a', 'g', 'u', 's')) 115 * .putAll('c', Arrays.asList('h', 'e', 'r', 'r', 'y')) 116 * .build(); 117 * 118 * // after deduplication, the resulting multimap is equivalent to 119 * 120 * static final ImmutableSetMultimap<Character, Character> FIRST_LETTER_MULTIMAP = 121 * ImmutableSetMultimap.<Character, Character>builder() 122 * .putAll('b', Arrays.asList('a', 'n')) 123 * .putAll('a', Arrays.asList('p', 'l', 'e', 's', 'a', 'r', 'g', 'u')) 124 * .putAll('c', Arrays.asList('a', 'r', 'o', 't', 'h', 'e', 'y')) 125 * .build(); 126 * } 127 * }</pre> 128 * 129 * @since 21.0 130 */ 131 public static <T, K, V> 132 Collector<T, ?, ImmutableSetMultimap<K, V>> flatteningToImmutableSetMultimap( 133 Function<? super T, ? extends K> keyFunction, 134 Function<? super T, ? extends Stream<? extends V>> valuesFunction) { 135 return CollectCollectors.flatteningToImmutableSetMultimap(keyFunction, valuesFunction); 136 } 137 138 /** Returns the empty multimap. */ 139 // Casting is safe because the multimap will never hold any elements. 140 @SuppressWarnings("unchecked") 141 public static <K, V> ImmutableSetMultimap<K, V> of() { 142 return (ImmutableSetMultimap<K, V>) EmptyImmutableSetMultimap.INSTANCE; 143 } 144 145 /** Returns an immutable multimap containing a single entry. */ 146 public static <K, V> ImmutableSetMultimap<K, V> of(K k1, V v1) { 147 ImmutableSetMultimap.Builder<K, V> builder = ImmutableSetMultimap.builder(); 148 builder.put(k1, v1); 149 return builder.build(); 150 } 151 152 /** 153 * Returns an immutable multimap containing the given entries, in order. Repeated occurrences of 154 * an entry (according to {@link Object#equals}) after the first are ignored. 155 */ 156 public static <K, V> ImmutableSetMultimap<K, V> of(K k1, V v1, K k2, V v2) { 157 ImmutableSetMultimap.Builder<K, V> builder = ImmutableSetMultimap.builder(); 158 builder.put(k1, v1); 159 builder.put(k2, v2); 160 return builder.build(); 161 } 162 163 /** 164 * Returns an immutable multimap containing the given entries, in order. Repeated occurrences of 165 * an entry (according to {@link Object#equals}) after the first are ignored. 166 */ 167 public static <K, V> ImmutableSetMultimap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) { 168 ImmutableSetMultimap.Builder<K, V> builder = ImmutableSetMultimap.builder(); 169 builder.put(k1, v1); 170 builder.put(k2, v2); 171 builder.put(k3, v3); 172 return builder.build(); 173 } 174 175 /** 176 * Returns an immutable multimap containing the given entries, in order. Repeated occurrences of 177 * an entry (according to {@link Object#equals}) after the first are ignored. 178 */ 179 public static <K, V> ImmutableSetMultimap<K, V> of( 180 K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) { 181 ImmutableSetMultimap.Builder<K, V> builder = ImmutableSetMultimap.builder(); 182 builder.put(k1, v1); 183 builder.put(k2, v2); 184 builder.put(k3, v3); 185 builder.put(k4, v4); 186 return builder.build(); 187 } 188 189 /** 190 * Returns an immutable multimap containing the given entries, in order. Repeated occurrences of 191 * an entry (according to {@link Object#equals}) after the first are ignored. 192 */ 193 public static <K, V> ImmutableSetMultimap<K, V> of( 194 K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) { 195 ImmutableSetMultimap.Builder<K, V> builder = ImmutableSetMultimap.builder(); 196 builder.put(k1, v1); 197 builder.put(k2, v2); 198 builder.put(k3, v3); 199 builder.put(k4, v4); 200 builder.put(k5, v5); 201 return builder.build(); 202 } 203 204 // looking for of() with > 5 entries? Use the builder instead. 205 206 /** Returns a new {@link Builder}. */ 207 public static <K, V> Builder<K, V> builder() { 208 return new Builder<>(); 209 } 210 211 /** 212 * A builder for creating immutable {@code SetMultimap} instances, especially {@code public static 213 * final} multimaps ("constant multimaps"). Example: 214 * 215 * <pre>{@code 216 * static final Multimap<String, Integer> STRING_TO_INTEGER_MULTIMAP = 217 * new ImmutableSetMultimap.Builder<String, Integer>() 218 * .put("one", 1) 219 * .putAll("several", 1, 2, 3) 220 * .putAll("many", 1, 2, 3, 4, 5) 221 * .build(); 222 * }</pre> 223 * 224 * <p>Builder instances can be reused; it is safe to call {@link #build} multiple times to build 225 * multiple multimaps in series. Each multimap contains the key-value mappings in the previously 226 * created multimaps. 227 * 228 * @since 2.0 229 */ 230 public static final class Builder<K, V> extends ImmutableMultimap.Builder<K, V> { 231 /** 232 * Creates a new builder. The returned builder is equivalent to the builder generated by {@link 233 * ImmutableSetMultimap#builder}. 234 */ 235 public Builder() { 236 super(); 237 } 238 239 @Override 240 Collection<V> newMutableValueCollection() { 241 return Platform.preservesInsertionOrderOnAddsSet(); 242 } 243 244 /** Adds a key-value mapping to the built multimap if it is not already present. */ 245 @CanIgnoreReturnValue 246 @Override 247 public Builder<K, V> put(K key, V value) { 248 super.put(key, value); 249 return this; 250 } 251 252 /** 253 * Adds an entry to the built multimap if it is not already present. 254 * 255 * @since 11.0 256 */ 257 @CanIgnoreReturnValue 258 @Override 259 public Builder<K, V> put(Entry<? extends K, ? extends V> entry) { 260 super.put(entry); 261 return this; 262 } 263 264 /** 265 * {@inheritDoc} 266 * 267 * @since 19.0 268 */ 269 @CanIgnoreReturnValue 270 @Beta 271 @Override 272 public Builder<K, V> putAll(Iterable<? extends Entry<? extends K, ? extends V>> entries) { 273 super.putAll(entries); 274 return this; 275 } 276 277 @CanIgnoreReturnValue 278 @Override 279 public Builder<K, V> putAll(K key, Iterable<? extends V> values) { 280 super.putAll(key, values); 281 return this; 282 } 283 284 @CanIgnoreReturnValue 285 @Override 286 public Builder<K, V> putAll(K key, V... values) { 287 return putAll(key, Arrays.asList(values)); 288 } 289 290 @CanIgnoreReturnValue 291 @Override 292 public Builder<K, V> putAll(Multimap<? extends K, ? extends V> multimap) { 293 for (Entry<? extends K, ? extends Collection<? extends V>> entry : 294 multimap.asMap().entrySet()) { 295 putAll(entry.getKey(), entry.getValue()); 296 } 297 return this; 298 } 299 300 @CanIgnoreReturnValue 301 @Override 302 Builder<K, V> combine(ImmutableMultimap.Builder<K, V> other) { 303 super.combine(other); 304 return this; 305 } 306 307 /** 308 * {@inheritDoc} 309 * 310 * @since 8.0 311 */ 312 @CanIgnoreReturnValue 313 @Override 314 public Builder<K, V> orderKeysBy(Comparator<? super K> keyComparator) { 315 super.orderKeysBy(keyComparator); 316 return this; 317 } 318 319 /** 320 * Specifies the ordering of the generated multimap's values for each key. 321 * 322 * <p>If this method is called, the sets returned by the {@code get()} method of the generated 323 * multimap and its {@link Multimap#asMap()} view are {@link ImmutableSortedSet} instances. 324 * However, serialization does not preserve that property, though it does maintain the key and 325 * value ordering. 326 * 327 * @since 8.0 328 */ 329 // TODO: Make serialization behavior consistent. 330 @CanIgnoreReturnValue 331 @Override 332 public Builder<K, V> orderValuesBy(Comparator<? super V> valueComparator) { 333 super.orderValuesBy(valueComparator); 334 return this; 335 } 336 337 /** Returns a newly-created immutable set multimap. */ 338 @Override 339 public ImmutableSetMultimap<K, V> build() { 340 Collection<Map.Entry<K, Collection<V>>> mapEntries = builderMap.entrySet(); 341 if (keyComparator != null) { 342 mapEntries = Ordering.from(keyComparator).<K>onKeys().immutableSortedCopy(mapEntries); 343 } 344 return fromMapEntries(mapEntries, valueComparator); 345 } 346 } 347 348 /** 349 * Returns an immutable set multimap containing the same mappings as {@code multimap}. The 350 * generated multimap's key and value orderings correspond to the iteration ordering of the {@code 351 * multimap.asMap()} view. Repeated occurrences of an entry in the multimap after the first are 352 * ignored. 353 * 354 * <p>Despite the method name, this method attempts to avoid actually copying the data when it is 355 * safe to do so. The exact circumstances under which a copy will or will not be performed are 356 * undocumented and subject to change. 357 * 358 * @throws NullPointerException if any key or value in {@code multimap} is null 359 */ 360 public static <K, V> ImmutableSetMultimap<K, V> copyOf( 361 Multimap<? extends K, ? extends V> multimap) { 362 return copyOf(multimap, null); 363 } 364 365 private static <K, V> ImmutableSetMultimap<K, V> copyOf( 366 Multimap<? extends K, ? extends V> multimap, Comparator<? super V> valueComparator) { 367 checkNotNull(multimap); // eager for GWT 368 if (multimap.isEmpty() && valueComparator == null) { 369 return of(); 370 } 371 372 if (multimap instanceof ImmutableSetMultimap) { 373 @SuppressWarnings("unchecked") // safe since multimap is not writable 374 ImmutableSetMultimap<K, V> kvMultimap = (ImmutableSetMultimap<K, V>) multimap; 375 if (!kvMultimap.isPartialView()) { 376 return kvMultimap; 377 } 378 } 379 380 return fromMapEntries(multimap.asMap().entrySet(), valueComparator); 381 } 382 383 /** 384 * Returns an immutable multimap containing the specified entries. The returned multimap iterates 385 * over keys in the order they were first encountered in the input, and the values for each key 386 * are iterated in the order they were encountered. If two values for the same key are {@linkplain 387 * Object#equals equal}, the first value encountered is used. 388 * 389 * @throws NullPointerException if any key, value, or entry is null 390 * @since 19.0 391 */ 392 @Beta 393 public static <K, V> ImmutableSetMultimap<K, V> copyOf( 394 Iterable<? extends Entry<? extends K, ? extends V>> entries) { 395 return new Builder<K, V>().putAll(entries).build(); 396 } 397 398 /** Creates an ImmutableSetMultimap from an asMap.entrySet. */ 399 static <K, V> ImmutableSetMultimap<K, V> fromMapEntries( 400 Collection<? extends Map.Entry<? extends K, ? extends Collection<? extends V>>> mapEntries, 401 @Nullable Comparator<? super V> valueComparator) { 402 if (mapEntries.isEmpty()) { 403 return of(); 404 } 405 ImmutableMap.Builder<K, ImmutableSet<V>> builder = 406 new ImmutableMap.Builder<>(mapEntries.size()); 407 int size = 0; 408 409 for (Entry<? extends K, ? extends Collection<? extends V>> entry : mapEntries) { 410 K key = entry.getKey(); 411 Collection<? extends V> values = entry.getValue(); 412 ImmutableSet<V> set = valueSet(valueComparator, values); 413 if (!set.isEmpty()) { 414 builder.put(key, set); 415 size += set.size(); 416 } 417 } 418 419 return new ImmutableSetMultimap<>(builder.build(), size, valueComparator); 420 } 421 422 /** 423 * Returned by get() when a missing key is provided. Also holds the comparator, if any, used for 424 * values. 425 */ 426 private final transient ImmutableSet<V> emptySet; 427 428 ImmutableSetMultimap( 429 ImmutableMap<K, ImmutableSet<V>> map, 430 int size, 431 @Nullable Comparator<? super V> valueComparator) { 432 super(map, size); 433 this.emptySet = emptySet(valueComparator); 434 } 435 436 // views 437 438 /** 439 * Returns an immutable set of the values for the given key. If no mappings in the multimap have 440 * the provided key, an empty immutable set is returned. The values are in the same order as the 441 * parameters used to build this multimap. 442 */ 443 @Override 444 public ImmutableSet<V> get(@Nullable K key) { 445 // This cast is safe as its type is known in constructor. 446 ImmutableSet<V> set = (ImmutableSet<V>) map.get(key); 447 return MoreObjects.firstNonNull(set, emptySet); 448 } 449 450 @LazyInit @RetainedWith private transient @Nullable ImmutableSetMultimap<V, K> inverse; 451 452 /** 453 * {@inheritDoc} 454 * 455 * <p>Because an inverse of a set multimap cannot contain multiple pairs with the same key and 456 * value, this method returns an {@code ImmutableSetMultimap} rather than the {@code 457 * ImmutableMultimap} specified in the {@code ImmutableMultimap} class. 458 */ 459 @Override 460 public ImmutableSetMultimap<V, K> inverse() { 461 ImmutableSetMultimap<V, K> result = inverse; 462 return (result == null) ? (inverse = invert()) : result; 463 } 464 465 private ImmutableSetMultimap<V, K> invert() { 466 Builder<V, K> builder = builder(); 467 for (Entry<K, V> entry : entries()) { 468 builder.put(entry.getValue(), entry.getKey()); 469 } 470 ImmutableSetMultimap<V, K> invertedMultimap = builder.build(); 471 invertedMultimap.inverse = this; 472 return invertedMultimap; 473 } 474 475 /** 476 * Guaranteed to throw an exception and leave the multimap unmodified. 477 * 478 * @throws UnsupportedOperationException always 479 * @deprecated Unsupported operation. 480 */ 481 @CanIgnoreReturnValue 482 @Deprecated 483 @Override 484 @DoNotCall("Always throws UnsupportedOperationException") 485 public final ImmutableSet<V> removeAll(Object key) { 486 throw new UnsupportedOperationException(); 487 } 488 489 /** 490 * Guaranteed to throw an exception and leave the multimap unmodified. 491 * 492 * @throws UnsupportedOperationException always 493 * @deprecated Unsupported operation. 494 */ 495 @CanIgnoreReturnValue 496 @Deprecated 497 @Override 498 @DoNotCall("Always throws UnsupportedOperationException") 499 public final ImmutableSet<V> replaceValues(K key, Iterable<? extends V> values) { 500 throw new UnsupportedOperationException(); 501 } 502 503 @LazyInit @RetainedWith private transient @Nullable ImmutableSet<Entry<K, V>> entries; 504 505 /** 506 * Returns an immutable collection of all key-value pairs in the multimap. Its iterator traverses 507 * the values for the first key, the values for the second key, and so on. 508 */ 509 @Override 510 public ImmutableSet<Entry<K, V>> entries() { 511 ImmutableSet<Entry<K, V>> result = entries; 512 return result == null ? (entries = new EntrySet<>(this)) : result; 513 } 514 515 private static final class EntrySet<K, V> extends ImmutableSet<Entry<K, V>> { 516 @Weak private final transient ImmutableSetMultimap<K, V> multimap; 517 518 EntrySet(ImmutableSetMultimap<K, V> multimap) { 519 this.multimap = multimap; 520 } 521 522 @Override 523 public boolean contains(@Nullable Object object) { 524 if (object instanceof Entry) { 525 Entry<?, ?> entry = (Entry<?, ?>) object; 526 return multimap.containsEntry(entry.getKey(), entry.getValue()); 527 } 528 return false; 529 } 530 531 @Override 532 public int size() { 533 return multimap.size(); 534 } 535 536 @Override 537 public UnmodifiableIterator<Entry<K, V>> iterator() { 538 return multimap.entryIterator(); 539 } 540 541 @Override 542 boolean isPartialView() { 543 return false; 544 } 545 } 546 547 private static <V> ImmutableSet<V> valueSet( 548 @Nullable Comparator<? super V> valueComparator, Collection<? extends V> values) { 549 return (valueComparator == null) 550 ? ImmutableSet.copyOf(values) 551 : ImmutableSortedSet.copyOf(valueComparator, values); 552 } 553 554 private static <V> ImmutableSet<V> emptySet(@Nullable Comparator<? super V> valueComparator) { 555 return (valueComparator == null) 556 ? ImmutableSet.<V>of() 557 : ImmutableSortedSet.<V>emptySet(valueComparator); 558 } 559 560 private static <V> ImmutableSet.Builder<V> valuesBuilder( 561 @Nullable Comparator<? super V> valueComparator) { 562 return (valueComparator == null) 563 ? new ImmutableSet.Builder<V>() 564 : new ImmutableSortedSet.Builder<V>(valueComparator); 565 } 566 567 /** 568 * @serialData number of distinct keys, and then for each distinct key: the key, the number of 569 * values for that key, and the key's values 570 */ 571 @GwtIncompatible // java.io.ObjectOutputStream 572 private void writeObject(ObjectOutputStream stream) throws IOException { 573 stream.defaultWriteObject(); 574 stream.writeObject(valueComparator()); 575 Serialization.writeMultimap(this, stream); 576 } 577 578 @Nullable 579 Comparator<? super V> valueComparator() { 580 return emptySet instanceof ImmutableSortedSet 581 ? ((ImmutableSortedSet<V>) emptySet).comparator() 582 : null; 583 } 584 585 @GwtIncompatible // java serialization 586 private static final class SetFieldSettersHolder { 587 static final Serialization.FieldSetter<ImmutableSetMultimap> EMPTY_SET_FIELD_SETTER = 588 Serialization.getFieldSetter(ImmutableSetMultimap.class, "emptySet"); 589 } 590 591 @GwtIncompatible // java.io.ObjectInputStream 592 // Serialization type safety is at the caller's mercy. 593 @SuppressWarnings("unchecked") 594 private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { 595 stream.defaultReadObject(); 596 Comparator<Object> valueComparator = (Comparator<Object>) stream.readObject(); 597 int keyCount = stream.readInt(); 598 if (keyCount < 0) { 599 throw new InvalidObjectException("Invalid key count " + keyCount); 600 } 601 ImmutableMap.Builder<Object, ImmutableSet<Object>> builder = ImmutableMap.builder(); 602 int tmpSize = 0; 603 604 for (int i = 0; i < keyCount; i++) { 605 Object key = stream.readObject(); 606 int valueCount = stream.readInt(); 607 if (valueCount <= 0) { 608 throw new InvalidObjectException("Invalid value count " + valueCount); 609 } 610 611 ImmutableSet.Builder<Object> valuesBuilder = valuesBuilder(valueComparator); 612 for (int j = 0; j < valueCount; j++) { 613 valuesBuilder.add(stream.readObject()); 614 } 615 ImmutableSet<Object> valueSet = valuesBuilder.build(); 616 if (valueSet.size() != valueCount) { 617 throw new InvalidObjectException("Duplicate key-value pairs exist for key " + key); 618 } 619 builder.put(key, valueSet); 620 tmpSize += valueCount; 621 } 622 623 ImmutableMap<Object, ImmutableSet<Object>> tmpMap; 624 try { 625 tmpMap = builder.build(); 626 } catch (IllegalArgumentException e) { 627 throw (InvalidObjectException) new InvalidObjectException(e.getMessage()).initCause(e); 628 } 629 630 FieldSettersHolder.MAP_FIELD_SETTER.set(this, tmpMap); 631 FieldSettersHolder.SIZE_FIELD_SETTER.set(this, tmpSize); 632 SetFieldSettersHolder.EMPTY_SET_FIELD_SETTER.set(this, emptySet(valueComparator)); 633 } 634 635 @GwtIncompatible // not needed in emulated source. 636 private static final long serialVersionUID = 0; 637}