package com.bernard.mcqinator.inutil;

import java.util.ArrayList;
import java.util.List;

/**
 * @author samy
 * @date on 23/07/17.
 */

public class ClassInutil {

    public static Class[] getAllInterface(Class c){
        List<Class> clazz = getAllInterface(c,new ArrayList<Class>());
        Class[] clazarray = new Class[clazz.size()];
        clazz.toArray(clazarray);
        return clazarray;
    }

    private static List<Class> getAllInterface(Class c,List<Class> l){
        for(Class k : c.getInterfaces()){
            l.add(k);
            getAllInterface(k,l);
        }
        if(c.getSuperclass() != null)
            getAllInterface(c.getSuperclass(),l);
        return l;
    }

}
