Java Reflection Generic Type from Field getGenericParameterClass(Field field)

Here you can find the source of getGenericParameterClass(Field field)

Description

get Generic Parameter Class

License

Apache License

Declaration

public static Class getGenericParameterClass(Field field) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.*;

public class Main {
    public static Class getGenericParameterClass(Field field) {
        Type genericType = field.getGenericType();
        return (Class) ((ParameterizedType) genericType).getActualTypeArguments()[0];
    }/*from w ww.  j  a  v  a2 s .c om*/
}

Related

  1. getGenericFieldType(Object target, String fieldName)
  2. getGenericFieldTypeFromPosition(Field field, int position)
  3. getGenericlyTypeCount(Field field)
  4. getGenericMultivalueType(final Field p)
  5. getGenericMultivalueType(final Field p)
  6. getGenericParameterClass(Field field)
  7. getGenericParameters(Field f)
  8. getGenericParametersInternal(Type genericFieldType)
  9. getGenericReturnType(Method method, Field field, boolean isAllowNull)