Here you can find the source of getGenericInterface(final Class sourceClass, final Class genericInterface)
public static Type getGenericInterface(final Class sourceClass, final Class genericInterface)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; public class Main { public static Type getGenericInterface(final Class sourceClass, final Class genericInterface) { Type[] types = sourceClass.getGenericInterfaces(); for (Type type : types) { if (type instanceof Class) { if (genericInterface.isAssignableFrom((Class) type)) { return type; }/* w w w. j a v a 2s . c o m*/ } else if (type instanceof ParameterizedType) { if (genericInterface.isAssignableFrom((Class) ((ParameterizedType) type).getRawType())) { return type; } } } return null; } }