private void add(Object[] elements, int n) { getReadyToExpandTo(size + n); System.arraycopy(elements, 0, contents, size, n); size += n; }
private void add(Object[] elements, int n) { getReadyToExpandTo(size + n); System.arraycopy(elements, 0, contents, size, n); size += n; }
/** * Adds {@code element} to the {@code ImmutableList}. * * @param element the element to add * @return this {@code Builder} object * @throws NullPointerException if {@code element} is null */ @CanIgnoreReturnValue @Override public Builder<E> add(E element) { checkNotNull(element); getReadyToExpandTo(size + 1); contents[size++] = element; return this; }
/** * Adds each element of {@code elements} to the {@code ImmutableList}. * * @param elements the {@code Iterable} to add to the {@code ImmutableList} * @return this {@code Builder} object * @throws NullPointerException if {@code elements} is null or contains a null element */ @CanIgnoreReturnValue @Override public Builder<E> addAll(Iterable<? extends E> elements) { checkNotNull(elements); if (elements instanceof Collection) { Collection<?> collection = (Collection<?>) elements; getReadyToExpandTo(size + collection.size()); if (collection instanceof ImmutableCollection) { ImmutableCollection<?> immutableCollection = (ImmutableCollection<?>) collection; size = immutableCollection.copyIntoArray(contents, size); return this; } } super.addAll(elements); return this; }
/** * Adds each element of {@code elements} to the {@code ImmutableList}. * * @param elements the {@code Iterable} to add to the {@code ImmutableList} * @return this {@code Builder} object * @throws NullPointerException if {@code elements} is null or contains a null element */ @CanIgnoreReturnValue @Override public Builder<E> addAll(Iterable<? extends E> elements) { checkNotNull(elements); if (elements instanceof Collection) { Collection<?> collection = (Collection<?>) elements; getReadyToExpandTo(size + collection.size()); if (collection instanceof ImmutableCollection) { ImmutableCollection<?> immutableCollection = (ImmutableCollection<?>) collection; size = immutableCollection.copyIntoArray(contents, size); return this; } } super.addAll(elements); return this; }
/** * Adds {@code element} to the {@code ImmutableList}. * * @param element the element to add * @return this {@code Builder} object * @throws NullPointerException if {@code element} is null */ @CanIgnoreReturnValue @Override public Builder<E> add(E element) { checkNotNull(element); getReadyToExpandTo(size + 1); contents[size++] = element; return this; }
/** * Adds {@code element} to the {@code ImmutableList}. * * @param element the element to add * @return this {@code Builder} object * @throws NullPointerException if {@code element} is null */ @CanIgnoreReturnValue @Override public Builder<E> add(E element) { checkNotNull(element); getReadyToExpandTo(size + 1); contents[size++] = element; return this; }
private void add(Object[] elements, int n) { getReadyToExpandTo(size + n); System.arraycopy(elements, 0, contents, size, n); size += n; }
private void add(Object[] elements, int n) { getReadyToExpandTo(size + n); System.arraycopy(elements, 0, contents, size, n); size += n; }
/** * Adds each element of {@code elements} to the {@code ImmutableList}. * * @param elements the {@code Iterable} to add to the {@code ImmutableList} * @return this {@code Builder} object * @throws NullPointerException if {@code elements} is null or contains a null element */ @CanIgnoreReturnValue @Override public Builder<E> addAll(Iterable<? extends E> elements) { checkNotNull(elements); if (elements instanceof Collection) { Collection<?> collection = (Collection<?>) elements; getReadyToExpandTo(size + collection.size()); if (collection instanceof ImmutableCollection) { ImmutableCollection<?> immutableCollection = (ImmutableCollection<?>) collection; size = immutableCollection.copyIntoArray(contents, size); return this; } } super.addAll(elements); return this; }
/** * Adds {@code element} to the {@code ImmutableList}. * * @param element the element to add * @return this {@code Builder} object * @throws NullPointerException if {@code element} is null */ @CanIgnoreReturnValue @Override public Builder<E> add(E element) { checkNotNull(element); getReadyToExpandTo(size + 1); contents[size++] = element; return this; }
/** * Adds each element of {@code elements} to the {@code ImmutableList}. * * @param elements the {@code Iterable} to add to the {@code ImmutableList} * @return this {@code Builder} object * @throws NullPointerException if {@code elements} is null or contains a null element */ @CanIgnoreReturnValue @Override public Builder<E> addAll(Iterable<? extends E> elements) { checkNotNull(elements); if (elements instanceof Collection) { Collection<?> collection = (Collection<?>) elements; getReadyToExpandTo(size + collection.size()); if (collection instanceof ImmutableCollection) { ImmutableCollection<?> immutableCollection = (ImmutableCollection<?>) collection; size = immutableCollection.copyIntoArray(contents, size); return this; } } super.addAll(elements); return this; }