コード例 #1
0
 /**
  * Associates all of the given map's keys and values in the built map. Duplicate keys are not
  * allowed, and will cause {@link #build} to fail.
  *
  * @throws NullPointerException if any key or value in {@code map} is null
  */
 public Builder<K, V> putAll(Map<? extends K, ? extends V> map) {
   ensureCapacity(size + map.size());
   for (Entry<? extends K, ? extends V> entry : map.entrySet()) {
     put(entry);
   }
   return this;
 }
コード例 #2
0
 /**
  * Associates {@code key} with {@code value} in the built map. Duplicate keys are not allowed,
  * and will cause {@link #build} to fail.
  */
 public Builder<K, V> put(K key, V value) {
   ensureCapacity(size + 1);
   TerminalEntry<K, V> entry = entryOf(key, value);
   // don't inline this: we want to fail atomically if key or value is null
   entries[size++] = entry;
   return this;
 }