Java tutorial
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Type; public class Main { private static final String TYPE_NAME_PREFIX = "class "; static boolean isTypeAssignableFrom(Type type, Class<?> clazz) { Class<?> aClazz = null; try { aClazz = getClass(type); } catch (ClassNotFoundException e) { e.printStackTrace(); } if (aClazz != null && clazz.isAssignableFrom(aClazz)) { return true; } return false; } private static Class<?> getClass(Type type) throws ClassNotFoundException { String className = getClassName(type); if (className == null || className.isEmpty()) { return null; } return Class.forName(className); } private static String getClassName(Type type) { if (type == null) { return ""; } String clazzName = type.toString(); if (clazzName.startsWith(TYPE_NAME_PREFIX)) { clazzName = clazzName.replace(TYPE_NAME_PREFIX, ""); } return clazzName; } }