Java Reflection Generic Type from Class getGenericType(Class target)

Here you can find the source of getGenericType(Class target)

Description

get Generic Type

License

Open Source License

Declaration

static public Type[] getGenericType(Class<?> target) 

Method Source Code

//package com.java2s;

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

public class Main {
    static public Type[] getGenericType(Class<?> target) {
        if (target == null)
            return new Type[0];
        Type[] types = target.getGenericInterfaces();
        if (types.length > 0) {
            return types;
        }//from ww  w .  j  av  a 2  s .  co  m
        Type type = target.getGenericSuperclass();
        if (type != null) {
            if (type instanceof ParameterizedType) {
                return new Type[] { type };
            }
        }
        return new Type[0];
    }
}

Related

  1. getGenericType(Class clazz, int index)
  2. getGenericType(Class propertyType)
  3. getGenericType(Class clazz)
  4. getGenericType(Class clazz)
  5. getGenericType(Class clazz, int index)
  6. getGenericType(Class type)
  7. getGenericType(Class type, Class clazz)
  8. getGenericType(Object o, Class declaringClass, int idx)
  9. getGenericType(Type type, Class rawType, int index)