diff --git a/common/source/java/ch/systemsx/cisd/common/utilities/ClassUtils.java b/common/source/java/ch/systemsx/cisd/common/utilities/ClassUtils.java index 16107789578bcef1784d9c7ef2730cd712a1c4ec..172f5ea84befd833e74ae2cb49ad98dbb38bfdb5 100644 --- a/common/source/java/ch/systemsx/cisd/common/utilities/ClassUtils.java +++ b/common/source/java/ch/systemsx/cisd/common/utilities/ClassUtils.java @@ -20,8 +20,6 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashSet; @@ -353,38 +351,4 @@ public final class ClassUtils } return field; } - - /** - * For given <var>clazz</var> tries to retrieve the generic interface of given class, then - * returns the type argument found at given <var>index</var>. - * - * @return <code>null</code> if not found. - */ - public final static Class<?> tryGetInterfaceTypeArgument(final Class<?> clazz, - final Class<?> genericInterfaceClass, final int index) - { - assert clazz != null : "Unspecified class"; - assert genericInterfaceClass != null && genericInterfaceClass.isInterface() : "Is not defined or not an interface"; - assert index > -1 : "Only positive index (> -1)"; - final Type[] genericInterfaces = clazz.getGenericInterfaces(); - for (final Type genericInterface : genericInterfaces) - { - // Only typed interface is an instance of 'ParameterizedType'. - // Other is just a 'Class'. - if (genericInterface instanceof ParameterizedType) - { - final ParameterizedType parameterizedType = (ParameterizedType) genericInterface; - if (genericInterfaceClass.isAssignableFrom((Class<?>) parameterizedType - .getRawType())) - { - final Type typeArgument = parameterizedType.getActualTypeArguments()[index]; - if (typeArgument instanceof Class) - { - return (Class<?>) typeArgument; - } - } - } - } - return null; - } } diff --git a/common/sourceTest/java/ch/systemsx/cisd/common/utilities/ClassUtilsTest.java b/common/sourceTest/java/ch/systemsx/cisd/common/utilities/ClassUtilsTest.java index 1f102295df137d246a72b9a48c40588b0226ce6a..745c9d467257fa0b59168d2322db76dfe30de1b0 100644 --- a/common/sourceTest/java/ch/systemsx/cisd/common/utilities/ClassUtilsTest.java +++ b/common/sourceTest/java/ch/systemsx/cisd/common/utilities/ClassUtilsTest.java @@ -205,31 +205,6 @@ public final class ClassUtilsTest assertSame(object, myExtendedClass.finalObject); } - @Test - public final void testGetInterfaceTypeArgument() - { - boolean fail = true; - try - { - ClassUtils.tryGetInterfaceTypeArgument(null, null, -1); - } catch (final AssertionError e) - { - fail = false; - } - assertFalse(fail); - Class<?> typeArgument = - ClassUtils.tryGetInterfaceTypeArgument(ExtendingA.class, IExtendingIA.class, 0); - assertNotNull(typeArgument); - typeArgument = - ClassUtils.tryGetInterfaceTypeArgument(ExtendingExtendingA.class, IB.class, 0); - assertNull(typeArgument); - // We do not support array type argument - typeArgument = - ClassUtils - .tryGetInterfaceTypeArgument(ExtendingArrayA.class, IExtendingIA.class, 0); - assertNull(typeArgument); - } - // // Helper Classes // @@ -309,10 +284,6 @@ public final class ClassUtilsTest { } - private static class ExtendingArrayA extends A implements IExtendingIA<String[]> - { - } - private static class ExtendingExtendingA extends ExtendingA implements IB, IA<String> { }