public static < T > Optional < T > visitWithResult ( MenuItem item , AbstractMenuItemVisitor < T > visitor ) { item . accept ( visitor ) ; return visitor . getResult ( ) ; }
Visits a menu item calling the appropriate function for the type and collects the result that is set by calling your visitor s setResult method .