package com.google.common.collect; import com.google.common.base.Preconditions; import java.util.Collection; import java.util.Iterator; /* loaded from: classes.dex */ public final class ObjectArrays { static T[] a(Collection collection, T[] tArr) { int size = collection.size(); if (tArr.length < size) { tArr = (T[]) b(tArr, size); } a((Iterable) collection, (Object[]) tArr); if (tArr.length > size) { tArr[size] = null; } return tArr; } public static T[] b(T[] tArr, int i) { return (T[]) Platform.a(tArr, i); } static T[] a(Object[] objArr, int i, int i2, T[] tArr) { Preconditions.b(i, i + i2, objArr.length); if (tArr.length < i2) { tArr = (T[]) b(tArr, i2); } else if (tArr.length > i2) { tArr[i2] = null; } System.arraycopy(objArr, i, tArr, 0, i2); return tArr; } static Object[] a(Collection collection) { Object[] objArr = new Object[collection.size()]; a((Iterable) collection, objArr); return objArr; } static Object[] a(Object[] objArr, int i, int i2) { Preconditions.b(i, i + i2, objArr.length); if (i2 == 0) { return new Object[0]; } Object[] objArr2 = new Object[i2]; System.arraycopy(objArr, i, objArr2, 0, i2); return objArr2; } private static Object[] a(Iterable iterable, Object[] objArr) { Iterator it = iterable.iterator(); int i = 0; while (it.hasNext()) { objArr[i] = it.next(); i++; } return objArr; } static Object[] a(Object... objArr) { a(objArr, objArr.length); return objArr; } static Object[] a(Object[] objArr, int i) { for (int i2 = 0; i2 < i; i2++) { a(objArr[i2], i2); } return objArr; } static Object a(Object obj, int i) { if (obj != null) { return obj; } throw new NullPointerException("at index " + i); } }