List of usage examples for java.lang.reflect Field getAnnotatedType
public AnnotatedType getAnnotatedType()
From source file:com.adobe.acs.commons.util.impl.ReflectionUtilTest.java
@Test public void testTestClazz() { for (Field field : TestClazz.class.getDeclaredFields()) { Type type = field.getAnnotatedType().getType(); switch (field.getName()) { case "stringList": assertTrue(isListType(type)); assertSame(String.class, getClassOrGenericParam(type)); assertTrue(isAssignableFrom(type, new ArrayList<String>().getClass())); break; case "integerSet": assertTrue(isSetType(type)); assertSame(Integer.class, getClassOrGenericParam(type)); assertTrue(isAssignableFrom(type, new HashSet<String>().getClass())); break; case "longCollection": assertTrue(isCollectionType(type)); assertSame(Long.class, getClassOrGenericParam(type)); assertTrue(isAssignableFrom(type, new ArrayList<Long>().getClass())); break; case "floatArray": assertTrue(isArray(type));/*from w w w . j av a2s. c om*/ assertSame(Float.class, getClassOrGenericParam(type)); assertTrue(isAssignableFrom(type, Float[].class)); break; case "atomicInteger": assertFalse(isListType(type)); assertFalse(isSetType(type)); assertFalse(isCollectionType(type)); assertFalse(isArray(type)); assertTrue(isAssignableFrom(type, Number.class)); assertSame(AtomicInteger.class, getClassOrGenericParam(type)); break; default: break; } } }