Here is a way:
import java.lang.reflect.Field; import java.lang.reflect.ParameterizedType; //maybe you are looping over fields or have a field of type Field f ParameterizedType collectionType = (ParameterizedType) f.getGenericType(); Class<?> actualClassOfElementInCollection = (Class<?>) collectionType.getActualTypeArguments()[0];
No comments:
Post a Comment
With great power comes great responsibility