jetbrick-commons/src/main/java/jetbrick/reflect/TypeResolverUtils.java
public static Class<?> getComponentType(Type type, Class<?> implClass, int index) {
        if (type instanceof Class) {
            Class<?> clazz = (Class<?>) type;
            if (clazz.isArray()) {
                return clazz.getComponentType();
            }
        } else if (type instanceof ParameterizedType) {
            ParameterizedType pt = (ParameterizedType) type;
            Type[] generics = pt.getActualTypeArguments();
            if (index < 0) {
                index = generics.length + index;
            }
            if (index < generics.length) {
                return getRawType(generics[index], implClass);
            }
        } else if (type instanceof GenericArrayType) {
            GenericArrayType gat = (GenericArrayType) type;
            return getRawType(gat.getGenericComponentType(), implClass);
        }
        return null;
    }
public static Class<?> getComponentType(Type type, Class<?> implClass, int index) {
        if (type instanceof Class) {
            Class<?> clazz = (Class<?>) type;
            if (clazz.isArray()) {
                return clazz.getComponentType();
            }
        } else if (type instanceof ParameterizedType) {
            ParameterizedType pt = (ParameterizedType) type;
            Type[] generics = pt.getActualTypeArguments();
            if (index < 0) {
                index = generics.length + index;
            }
            if (index < generics.length) {
                return getRawType(generics[index], implClass);
            }
        } else if (type instanceof GenericArrayType) {
            GenericArrayType gat = (GenericArrayType) type;
            return getRawType(gat.getGenericComponentType(), implClass);
        }
        return null;
    }
public static Class < ? > getComponentType ( Type type , Class < ? > implClass , int index ) { if ( type instanceof Class ) { Class < ? > clazz = ( Class < ? > ) type ; if ( clazz . isArray ( ) ) { return clazz . getComponentType ( ) ; } } else if ( type instanceof ParameterizedType ) { ParameterizedType pt = ( ParameterizedType ) type ; Type [ ] generics = pt . getActualTypeArguments ( ) ; if ( index < 0 ) { index = generics . length + index ; } if ( index < generics . length ) { return getRawType ( generics [ index ] , implClass ) ; } } else if ( type instanceof GenericArrayType ) { GenericArrayType gat = ( GenericArrayType ) type ; return getRawType ( gat . getGenericComponentType ( ) , implClass ) ; } return null ; }
Returns the component type of the given type.
Returns <code>null</code> if given type does not have a single
component type. For example the following types all have the
component-type MyClass:
<ul>
<li>MyClass[]</li>
<li>List&lt;MyClass&gt;</li>
<li>Foo&lt;? extends MyClass&gt;</li>
<li>Bar&lt;? super MyClass&gt;</li>
<li>&lt;T extends MyClass&gt; T[]</li>
</ul>

Index represents the index of component type, when class supports more then one.
For example, <code>Map&lt;A, B&gt;</code> has 2 component types. If index is 0 or positive,
than it represents order of component type. If the value is negative, then it represents
component type counted from the end! Therefore, the default value of <code>-1</code>
always returns the <b>last</b> component type.

@param type - type
@param implClass - implementation class
@param index - index of component type
@return component type
Returns the component type of the given type . Returns <code > null< / code > if given type does not have a single component type . For example the following types all have the component - type MyClass : <ul > <li > MyClass [] < / li > <li > List&lt ; MyClass&gt ; < / li > <li > Foo&lt ; ? extends MyClass&gt ; < / li > <li > Bar&lt ; ? super MyClass&gt ; < / li > <li > &lt ; T extends MyClass&gt ; T [] < / li > < / ul >