public static Component scan ( Component root , ScannerMatcher matcher ) { if ( matcher . matches ( root ) ) return root ; if ( ! ( root instanceof Container ) ) return null ; Container container = ( Container ) root ; for ( Component component : container . getComponents ( ) ) { Component found = scan ( component , matcher ) ; if ( found != null ) return found ; } return null ; }
Scans a component tree searching for the one which is matched by the given matcher . In case of multiple matches the firs one found is returned .