Java Reflection Generic Type from Class getGenericClass(Object o)

Here you can find the source of getGenericClass(Object o)

Description

get Generic Class

License

Open Source License

Declaration

public static Class getGenericClass(Object o) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.ParameterizedType;

public class Main {
    public static Class getGenericClass(Object o) {
        ParameterizedType parameterizedType = (ParameterizedType) o.getClass().getGenericSuperclass();
        return (Class) parameterizedType.getActualTypeArguments()[0];
    }/*from ww  w.  j  a v a  2 s  . c  om*/
}

Related

  1. getGenericClass(Class cls)
  2. getGenericClass(final Class class1)
  3. getGenericClass(final Class parametrizedClass, int pos)
  4. getGenericClass(final Class parametrizedClass, int pos)
  5. getGenericClass(final Method method)
  6. getGenericClass(Object object, int index)
  7. getGenericClass(Object source, ParameterizedType type)
  8. getGenericClass(Type type)
  9. getGenericClassByIndex(Type genericType, int index)