Java Reflection Generic Type from Class getGenericTypes(Class clazz)

Here you can find the source of getGenericTypes(Class clazz)

Description

get Generic Types

License

Apache License

Declaration

public static Type[] getGenericTypes(Class<?> clazz) 

Method Source Code

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

import java.lang.reflect.*;

public class Main {
    public static Type[] getGenericTypes(Class<?> clazz) {

        Class<?> myClass = clazz;

        if (!(clazz.getGenericSuperclass() instanceof ParameterizedType)) {
            myClass = clazz.getSuperclass();
        }//from  w  w w  .j  a va2  s.c  o  m

        Type superClass = myClass.getGenericSuperclass();
        ParameterizedType type = (ParameterizedType) superClass;
        return type.getActualTypeArguments();
    }
}

Related

  1. getGenericTypeForMapProperty(Class javaClass, String propertyName, boolean isKeyType)
  2. getGenericTypeOfInterface(Class clazz, Class specificInterface)
  3. getGenericTypeOfParameter(Class clazz, String method, int parameterIndex)
  4. getGenericTypeParameter(Class aClass, Class genericClass, int index)
  5. getGenericTypes(Class c)
  6. getGenericTypes(final Class iClass)
  7. getGenericTypesImpl(ParameterizedType ptype, List> classes)