Java Reflection Generic Type getGenericFirst(Object obj)

Here you can find the source of getGenericFirst(Object obj)

Description

get Generic First

License

Apache License

Declaration

public static Class getGenericFirst(Object obj) 

Method Source Code


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

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class Main {

    public static Class getGenericFirst(Object obj) {
        Type type = (Type) obj.getClass().getGenericSuperclass();
        ParameterizedType pt = (ParameterizedType) type;
        Class classz = ((Class) pt.getActualTypeArguments()[0]);
        return classz;
    }/*from  www  .  j  ava  2  s. c  o  m*/
}

Related

  1. getGenericArguments(Type type)
  2. getGenericElementType(Type type)
  3. getGenerics(Type genericType)
  4. getGenerics(Type t)
  5. getGenericString(AccessibleObject ao)
  6. getGenericSuperType(Type t)