private Class<?> resolveArgument(Type type) {
    if (type instanceof ParameterizedType) {
      ParameterizedType paramType = (ParameterizedType) type;
      return resolveClass(paramType.getActualTypeArguments()[0]);
    } else if (type instanceof TypeVariable) {
      return resolveClass(type);
    } else if (type instanceof Class) {
      TypeVariable<?>[] typeParams = ((Class<?>) type).getTypeParameters();
      return resolveClass(typeParams[0]);
    }
    return null;
  }
private Class < ? > resolveArgument ( Type type ) { if ( type instanceof ParameterizedType ) { ParameterizedType paramType = ( ParameterizedType ) type ; return resolveClass ( paramType . getActualTypeArguments ( ) [ 0 ] ) ; } else if ( type instanceof TypeVariable ) { return resolveClass ( type ) ; } else if ( type instanceof Class ) { TypeVariable < ? > [ ] typeParams = ( ( Class < ? > ) type ) . getTypeParameters ( ) ; return resolveClass ( typeParams [ 0 ] ) ; } return null ; }
Resolves the generic argument for the given type.