/** * Adds the {@code values} to the {@code list}. This is a helper method * used by generated code. Users should ignore it. * * @throws NullPointerException if any of the elements of {@code values} is * null. */ protected static <T> void addAll(final Iterable<T> values, final Collection<? super T> list) { if (values instanceof LazyStringList) { // For StringOrByteStringLists, check the underlying elements to avoid // forcing conversions of ByteStrings to Strings. checkForNullValues(((LazyStringList) values).getUnderlyingElements()); } else { checkForNullValues(values); } if (values instanceof Collection) { final Collection<T> collection = (Collection<T>) values; list.addAll(collection); } else { for (final T value : values) { list.add(value); } } }
/** * Adds the {@code values} to the {@code list}. This is a helper method * used by generated code. Users should ignore it. * * @throws NullPointerException if {@code values} or any of the elements of * {@code values} is null. When that happens, some elements of * {@code values} may have already been added to the result {@code list}. */ protected static <T> void addAll(final Iterable<T> values, final Collection<? super T> list) { if (values == null) { throw new NullPointerException(); } if (values instanceof LazyStringList) { // For StringOrByteStringLists, check the underlying elements to avoid // forcing conversions of ByteStrings to Strings. checkForNullValues(((LazyStringList) values).getUnderlyingElements()); list.addAll((Collection<T>) values); } else if (values instanceof Collection) { checkForNullValues(values); list.addAll((Collection<T>) values); } else { for (final T value : values) { if (value == null) { throw new NullPointerException(); } list.add(value); } } }
/** * Adds the {@code values} to the {@code list}. This is a helper method * used by generated code. Users should ignore it. * * @throws NullPointerException if {@code values} or any of the elements of * {@code values} is null. When that happens, some elements of * {@code values} may have already been added to the result {@code list}. */ protected static <T> void addAll(final Iterable<T> values, final Collection<? super T> list) { if (values == null) { throw new NullPointerException(); } if (values instanceof LazyStringList) { // For StringOrByteStringLists, check the underlying elements to avoid // forcing conversions of ByteStrings to Strings. checkForNullValues(((LazyStringList) values).getUnderlyingElements()); list.addAll((Collection<T>) values); } else if (values instanceof Collection) { checkForNullValues(values); list.addAll((Collection<T>) values); } else { for (final T value : values) { if (value == null) { throw new NullPointerException(); } list.add(value); } } }
/** * Adds the {@code values} to the {@code list}. This is a helper method * used by generated code. Users should ignore it. * * @throws NullPointerException if any of the elements of {@code values} is * null. When that happens, some elements of {@code values} may have already * been added to the result {@code list}. */ protected static <T> void addAll(final Iterable<T> values, final Collection<? super T> list) { if (values instanceof LazyStringList) { // For StringOrByteStringLists, check the underlying elements to avoid // forcing conversions of ByteStrings to Strings. checkForNullValues(((LazyStringList) values).getUnderlyingElements()); list.addAll((Collection<T>) values); } else if (values instanceof Collection) { checkForNullValues(values); list.addAll((Collection<T>) values); } else { for (final T value : values) { if (value == null) { throw new NullPointerException(); } list.add(value); } } }