From fd7563673e5b59e38383457b433e5fbba6090eba Mon Sep 17 00:00:00 2001 From: Daniel Frett Date: Mon, 24 Jul 2023 11:10:53 -0600 Subject: [PATCH] remove v4.0.1 deprecated CollectionUtils --- .../android/common/util/CollectionUtils.java | 37 ------------------- .../common/util/CollectionUtilsTest.java | 30 --------------- 2 files changed, 67 deletions(-) delete mode 100644 gto-support-core/src/main/java/org/ccci/gto/android/common/util/CollectionUtils.java delete mode 100644 gto-support-core/src/test/java/org/ccci/gto/android/common/util/CollectionUtilsTest.java diff --git a/gto-support-core/src/main/java/org/ccci/gto/android/common/util/CollectionUtils.java b/gto-support-core/src/main/java/org/ccci/gto/android/common/util/CollectionUtils.java deleted file mode 100644 index 620037b23..000000000 --- a/gto-support-core/src/main/java/org/ccci/gto/android/common/util/CollectionUtils.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.ccci.gto.android.common.util; - -import androidx.annotation.Nullable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; - -/** - * @deprecated Since v4.0.1, This was only being used by jsonapi, so we made it internal to that project. - */ -@Deprecated -public class CollectionUtils { - @Nullable - @SuppressWarnings("unchecked") - public static T newCollection(@Nullable final Class type) { - if (type == null) { - return null; - } - - // try creating the collection via reflection, suppress exceptions to allow generic types to be used. - try { - return type.newInstance(); - } catch (final Throwable ignored) { - } - - // try using some generic collection type - if (type.isAssignableFrom(ArrayList.class)) { - return (T) new ArrayList(); - } else if (type.isAssignableFrom(HashSet.class)) { - return (T) new HashSet(); - } else { - throw new IllegalArgumentException( - type + " is currently not a supported Collection type, try something more generic"); - } - } -} diff --git a/gto-support-core/src/test/java/org/ccci/gto/android/common/util/CollectionUtilsTest.java b/gto-support-core/src/test/java/org/ccci/gto/android/common/util/CollectionUtilsTest.java deleted file mode 100644 index 7635caf83..000000000 --- a/gto-support-core/src/test/java/org/ccci/gto/android/common/util/CollectionUtilsTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.ccci.gto.android.common.util; - -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -import static org.ccci.gto.android.common.util.CollectionUtils.newCollection; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -public class CollectionUtilsTest { - @Test - public void verifyNewCollectionNullType() throws Exception { - assertNull(newCollection(null)); - } - - @Test - public void verifyNewCollectionSupported() throws Exception { - for (final Class type : Arrays - .asList(Collection.class, List.class, ArrayList.class, LinkedList.class, Set.class, HashSet.class)) { - assertTrue(type.isInstance(newCollection(type))); - } - } -}