Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.datastax.driver.mapping;
Utility methods related to reflection.
 class ReflectionUtils {

Gets a type argument from a parameterized type.

pt the parameterized type.
arg the index of the argument to retrieve.
name the name of the element (field or method argument).
the type argument.
    static Class<?> getParam(ParameterizedType ptint argString name) {
        Type ft = pt.getActualTypeArguments()[arg];
        if (!(ft instanceof Class))
            throw new IllegalArgumentException(String.format("Cannot map parameter of class %s for %s"ptname));
        return (Class<?>)ft;
New to GrepCode? Check out our FAQ X