Java Reflection Generic Type from Field getGenericParametersInternal(Type genericFieldType)

Here you can find the source of getGenericParametersInternal(Type genericFieldType)

Description

get Generic Parameters Internal

License

Open Source License

Declaration

private static Class<?>[] getGenericParametersInternal(Type genericFieldType) 

Method Source Code

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

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

public class Main {
    private static Class<?>[] getGenericParametersInternal(Type genericFieldType) {
        if (genericFieldType instanceof ParameterizedType) {
            ParameterizedType aType = (ParameterizedType) genericFieldType;
            Type[] fieldArgTypes = aType.getActualTypeArguments();
            Class<?>[] clazzes = new Class<?>[fieldArgTypes.length];
            for (int i = 0; i < clazzes.length; i++) {
                clazzes[i] = (Class<?>) fieldArgTypes[i];
            }// ww w  . ja v  a 2s .co m
            return clazzes;
        }
        return new Class<?>[] {};
    }
}

Related

  1. getGenericMultivalueType(final Field p)
  2. getGenericMultivalueType(final Field p)
  3. getGenericParameterClass(Field field)
  4. getGenericParameterClass(Field field)
  5. getGenericParameters(Field f)
  6. getGenericReturnType(Method method, Field field, boolean isAllowNull)
  7. getGenericsTypeFromCollectionField(Field field)
  8. getGenericType(Field field)
  9. getGenericType(Field field)