code: public static Class[] extractAllInterfaces(Object o)
    {
      Set<Class> interfaces = new LinkedHashSet<Class>();
  
      Class c = o.getClass();
      do
      {
        interfaces.addAll(Arrays.asList(c.getInterfaces()));
        c = c.getSuperclass();
      }
      while(c != null);
  
      return interfaces.toArray(new Class[interfaces.size()]);
    }
docs: Utility which extract the interfaces implemented by o: it goes up the chain of inheritance
  to find all the interfaces.
  
  @param o
  @return all the interfaces implemented by o