private static void addInterfaces ( Object obj , Set < Class < ? > > interfaces ) { Class < ? > [ ] generatorInterfaces = null ; Class < ? > superClass = null ; if ( obj instanceof Class ) { generatorInterfaces = ( ( Class < ? > ) obj ) . getInterfaces ( ) ; superClass = ( ( Class < ? > ) obj ) . getSuperclass ( ) ; } else { generatorInterfaces = obj . getClass ( ) . getInterfaces ( ) ; superClass = obj . getClass ( ) . getSuperclass ( ) ; } for ( Class < ? > generatorInterface : generatorInterfaces ) { interfaces . add ( generatorInterface ) ; addInterfaces ( generatorInterface , interfaces ) ; } if ( superClass != null && superClass != Object . class ) { addInterfaces ( superClass , interfaces ) ; } }
Adds all the interfaces of the object passed in parameter in the set of interfaces .