public static Stream < Class < ? > > getInterfacesAsStream ( Class < ? > clazz ) { return getSuperclassesAsStream ( clazz , true ) . flatMap ( superClass -> Stream . concat ( superClass . isInterface ( ) ? Stream . of ( superClass ) : Stream . empty ( ) , Arrays . stream ( superClass . getInterfaces ( ) ) . flatMap ( ClassHelper :: getInterfacesAsStream ) ) ) . distinct ( ) ; }
Get a stream of all interfaces of the given class including extended interfaces and interfaces of all superclasses . If the given class is an interface it will be included in the result otherwise not .