Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static boolean implementsInterface(Class<?> type, Class<?> interfaceType, boolean searchInSuperclasses) { boolean found = false; for (Class<?> item : type.getInterfaces()) { if (item.equals(interfaceType)) { found = true; break; } } if (found) { return true; } else { if (searchInSuperclasses && type.getSuperclass() != null) { return implementsInterface(type.getSuperclass(), interfaceType, searchInSuperclasses); } } return false; } }