GenericsUtil { protected static boolean isNotTypeVariable( Type type) throws IllegalStateException { if (type instanceof Class) { return true; } else if (type instanceof TypeVariable) { return false; } else if (type instanceof ParameterizedType) { return true; } else if (type instanceof GenericArrayType) { return true; } throw new IllegalStateException("Type(" + type + ") is not instance of " + TypeVariable.class.getName() + ", " + ParameterizedType.class .getName() + ", " + GenericArrayType.class.getName() + " nor " + Class.class.getName()); }  @SuppressWarnings("rawtypes") static Class[] resolveParameterizedClass(Class<T> genericClass,
            Class<? extends T> descendantClass); static Class<? extends Object> resolveParameterizedClass(
            Class<T> genericClass, Class<? extends T> descendantClass,
            int index);  }
@Test public void testsNotTypeVariable01() throws Exception { boolean result = GenericsUtil.isNotTypeVariable(String.class); assertTrue(result); }
@Test public void testIsNotTypeVariable02() throws Exception { Type type = getTypeVariable(AbstractList.class, GenericsUtil_ArrayListStub01.class, 0); boolean result = GenericsUtil.isNotTypeVariable(type); assertFalse(result); }
@Test public void testIsNotTypeVariable03() throws Exception { Type type = new GenericsUtil_WildCardTypeStub01(); try { GenericsUtil.isNotTypeVariable(type); fail("例外がスローされませんでした。"); } catch (IllegalStateException e) { assertEquals("Type(" + type + ") is not instance of " + TypeVariable.class.getName() + ", " + ParameterizedType.class.getName() + ", " + GenericArrayType.class.getName() + " nor " + Class.class .getName(), e.getMessage()); assertEquals(IllegalStateException.class.getName(), e.getClass() .getName()); } }
@Test public void testIsNotTypeVariable04() throws Exception { Type type = GenericsUtil_ArrayListStub01.class.getGenericSuperclass(); boolean result = GenericsUtil.isNotTypeVariable(type); assertTrue(result); }
@Test public void testIsNotTypeVariable05() throws Exception { Type type = new GenericsUtil_GenericArrayTypeStub01(); boolean result = GenericsUtil.isNotTypeVariable(type); assertTrue(result); }