code: private static TypeVariable<?> getTypeVariable(Type type) {
          // find root type if generic array
          while (type instanceof GenericArrayType) {
              type = ((GenericArrayType) type).getGenericComponentType();
          }
          
          // return type variable if valid
          if (type instanceof TypeVariable) {
              return (TypeVariable<?>) type;
          }
          
          // non-type variable, return null
          return null;
      }
docs: Get the {@link TypeVariable} instance for the specified {@link Type}.
  If the type is not a {@link TypeVariable}, then <code>null</code> is
  returned.  If the type is a {@link GenericArrayType}, its root type is
  looked up and then checked.
  
  @param type  The associated type
  
  @return  The type variable instance or <code>null</code>